1.4. FP4转换与数据移动
要使用这些函数,请在程序中包含头文件 cuda_fp4.h。
枚举
- __nv_fp4_interpretation_t
-
列举将4位值作为
fp4类型时的可能解释。
Functions
- __host__ __device__ __nv_fp4x2_storage_t __nv_cvt_bfloat16raw2_to_fp4x2(const __nv_bfloat162_raw x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
将输入向量中两个
nv_bfloat16精度的数字(打包在__nv_bfloat162_rawx中)转换为两个fp4类型值的向量,使用指定的舍入模式并对超出范围的值进行饱和处理。 - __host__ __device__ __nv_fp4_storage_t __nv_cvt_bfloat16raw_to_fp4(const __nv_bfloat16_raw x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
将输入的
nv_bfloat16精度x转换为指定类型的fp4格式,使用指定的舍入模式并对超出范围的值进行饱和处理。 - __host__ __device__ __nv_fp4x2_storage_t __nv_cvt_double2_to_fp4x2(const double2 x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
将输入向量中两个打包在
double2x中的双精度数,使用指定的舍入模式转换为所请求类型的两个fp4值向量,并对超出范围的值进行饱和处理。 - __host__ __device__ __nv_fp4_storage_t __nv_cvt_double_to_fp4(const double x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
将输入的
double精度x转换为指定舍入模式的fp4类型,并对超出范围的值进行饱和处理。 - __host__ __device__ __nv_fp4x2_storage_t __nv_cvt_float2_to_fp4x2(const float2 x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
将输入向量中的两个
single精度数(打包在float2x中)转换为两个fp4类型值的向量,使用指定的舍入模式并对超出范围的值进行饱和处理。 - __host__ __device__ __nv_fp4_storage_t __nv_cvt_float_to_fp4(const float x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
使用指定的舍入模式将输入的
single精度x转换为请求类型的fp4,并对超出范围的值进行饱和处理。 - __host__ __device__ __half_raw __nv_cvt_fp4_to_halfraw(const __nv_fp4_storage_t x, const __nv_fp4_interpretation_t fp4_interpretation)
-
将指定类型的输入
fp4x转换为half精度。 - __host__ __device__ __half2_raw __nv_cvt_fp4x2_to_halfraw2(const __nv_fp4x2_storage_t x, const __nv_fp4_interpretation_t fp4_interpretation)
-
将指定类型的两个
fp4值的输入向量转换为打包在__half2_raw结构中的两个half精度值的向量。 - __host__ __device__ __nv_fp4x2_storage_t __nv_cvt_halfraw2_to_fp4x2(const __half2_raw x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
将输入向量中两个打包在
__half2_rawx的半精度数,使用指定的舍入模式转换为两个fp4类型值的向量,并对超出范围的值进行饱和处理。 - __host__ __device__ __nv_fp4_storage_t __nv_cvt_halfraw_to_fp4(const __half_raw x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
使用指定的舍入模式将输入的
half精度x转换为请求类型的fp4,并对超出范围的值进行饱和处理。 - __host__ __device__ __nv_fp4_e2m1::__nv_fp4_e2m1()
-
默认构造函数。
- __host__ __device__ __nv_fp4_e2m1::__nv_fp4_e2m1(const unsigned long int val)
-
从
unsignedlongint数据类型构造,对于超出范围的值依赖于__NV_SATFINITE的行为。 - __host__ __device__ __nv_fp4_e2m1::__nv_fp4_e2m1(const double f)
-
从
double数据类型构造,对于超出范围的值依赖于__NV_SATFINITE行为,并使用cudaRoundNearest舍入模式。 - __host__ __device__ __nv_fp4_e2m1::__nv_fp4_e2m1(const long int val)
-
从
longint数据类型构造,对于超出范围的值依赖于__NV_SATFINITE的行为。 - __host__ __device__ __nv_fp4_e2m1::__nv_fp4_e2m1(const float f)
-
从
float数据类型构造,对于超出范围的值依赖__NV_SATFINITE行为,并使用cudaRoundNearest舍入模式。 - __host__ __device__ __nv_fp4_e2m1::__nv_fp4_e2m1(const int val)
-
从
int数据类型构造,对于超出范围的值依赖于__NV_SATFINITE的行为。 - __host__ __device__ __nv_fp4_e2m1::__nv_fp4_e2m1(const unsigned short int val)
-
从
unsignedshortint数据类型构造,对于超出范围的值依赖于__NV_SATFINITE的行为。 - __host__ __device__ __nv_fp4_e2m1::__nv_fp4_e2m1(const long long int val)
-
从
longlongint数据类型构造,对于超出范围的值依赖于__NV_SATFINITE的行为。 - __host__ __device__ __nv_fp4_e2m1::__nv_fp4_e2m1(const short int val)
-
从
shortint数据类型的构造函数。 - __host__ __device__ __nv_fp4_e2m1::__nv_fp4_e2m1(const __nv_bfloat16 f)
-
从
__nv_bfloat16数据类型的构造函数,对于超出范围的值依赖于__NV_SATFINITE行为,并使用cudaRoundNearest舍入模式。 - __host__ __device__ __nv_fp4_e2m1::__nv_fp4_e2m1(const unsigned int val)
-
从
unsignedint数据类型的构造函数,对于超出范围的值依赖于__NV_SATFINITE的行为。 - __host__ __device__ __nv_fp4_e2m1::__nv_fp4_e2m1(const unsigned long long int val)
-
从
unsignedlonglongint数据类型的构造函数,对于超出范围的值依赖于__NV_SATFINITE的行为。 - __host__ __device__ __nv_fp4_e2m1::__nv_fp4_e2m1(const __half f)
-
从
__half数据类型构造,依赖__NV_SATFINITE处理超出范围值的行为,并使用cudaRoundNearest舍入模式。 - __host__ __device__ __nv_fp4x2_e2m1::__nv_fp4x2_e2m1(const double2 f)
-
从
double2数据类型构造,对于超出范围的值依赖于__NV_SATFINITE的行为。 - __host__ __device__ __nv_fp4x2_e2m1::__nv_fp4x2_e2m1(const __nv_bfloat162 f)
-
从
__nv_bfloat162数据类型构造,对于超出范围的值依赖于__NV_SATFINITE的行为。 - __host__ __device__ __nv_fp4x2_e2m1::__nv_fp4x2_e2m1(const __half2 f)
-
从
__half2数据类型构造,对于超出范围的值依赖于__NV_SATFINITE的行为。 - __host__ __device__ __nv_fp4x2_e2m1::__nv_fp4x2_e2m1(const float2 f)
-
从
float2数据类型构造,对于超出范围的值依赖于__NV_SATFINITE的行为。 - __host__ __device__ __nv_fp4x2_e2m1::__nv_fp4x2_e2m1()
-
默认构造函数。
- __host__ __device__ __nv_fp4x4_e2m1::__nv_fp4x4_e2m1()
-
默认构造函数。
- __host__ __device__ __nv_fp4x4_e2m1::__nv_fp4x4_e2m1(const __nv_bfloat162 flo, const __nv_bfloat162 fhi)
-
从一对
__nv_bfloat162数据类型值构造,对于超出范围的值依赖于__NV_SATFINITE的行为。 - __host__ __device__ __nv_fp4x4_e2m1::__nv_fp4x4_e2m1(const double4 f)
-
从
double4向量数据类型构造,对于超出范围的值依赖于__NV_SATFINITE的行为。 - __host__ __device__ __nv_fp4x4_e2m1::__nv_fp4x4_e2m1(const float4 f)
-
从
float4向量数据类型构造,对于超出范围的值依赖于__NV_SATFINITE的行为。 - __host__ __device__ __nv_fp4x4_e2m1::__nv_fp4x4_e2m1(const __half2 flo, const __half2 fhi)
-
从一对
__half2数据类型值构造,对于超出范围的值依赖于__NV_SATFINITE的行为。
类型定义
- __nv_fp4_storage_t
-
用于存储
fp4浮点数的8位unsignedinteger类型抽象。 - __nv_fp4x2_storage_t
-
用于存储
fp4浮点数对的8位unsignedinteger类型抽象。 - __nv_fp4x4_storage_t
-
用于存储
fp4浮点数四元组的16位unsignedinteger类型抽象。
1.4.1. 枚举
1.4.2. 功能
-
__host__ __device__ __nv_fp4x2_storage_t __nv_cvt_bfloat16raw2_to_fp4x2(const __nv_bfloat162_raw x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
将输入向量中两个
nv_bfloat16精度的数字(打包在__nv_bfloat162_rawx中)转换为两个fp4类型的值向量,使用指定的舍入模式并饱和处理超出范围的值。将输入向量
x转换为由fp4_interpretation参数指定类型的两个fp4值向量,使用rounding参数指定的舍入模式。超出范围的大数值会饱和至相同符号的MAXNORM值。NaN输入值将转换为正MAXNORM。- Returns
-
__nv_fp4x2_storage_t值保存转换的结果。
-
__host__ __device__ __nv_fp4_storage_t __nv_cvt_bfloat16raw_to_fp4(const __nv_bfloat16_raw x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
将输入的
nv_bfloat16精度x转换为指定类型的fp4格式,使用指定的舍入模式并对超出范围的值进行饱和处理。将输入
x转换为由fp4_interpretation参数指定类型的fp4格式,使用rounding参数指定的舍入模式。超出范围的大数值会饱和至相同符号的MAXNORM值。NaN输入值将转换为正MAXNORM。- Returns
-
__nv_fp4_storage_t值保存转换的结果。
-
__host__ __device__ __nv_fp4x2_storage_t __nv_cvt_double2_to_fp4x2(const double2 x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
将输入向量中两个
double精度的数字(打包在double2x中)转换为两个fp4类型值的向量,使用指定的舍入模式并对超出范围的值进行饱和处理。将输入向量
x转换为由fp4_interpretation参数指定类型的两个fp4值向量,使用rounding参数指定的舍入模式。超出范围的大数值会饱和至相同符号的MAXNORM值。NaN输入值将转换为正MAXNORM。- Returns
-
__nv_fp4x2_storage_t值保存转换结果。
-
__host__ __device__ __nv_fp4_storage_t __nv_cvt_double_to_fp4(const double x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
将输入的
double精度x转换为指定舍入模式的fp4类型,并对超出范围的值进行饱和处理。将输入
x转换为由fp4_interpretation参数指定类型的fp4格式,使用rounding参数指定的舍入模式。超出范围的大数值会饱和至相同符号的MAXNORM值。NaN输入值将转换为正MAXNORM。- Returns
-
__nv_fp4_storage_t值保存转换结果。
-
__host__ __device__ __nv_fp4x2_storage_t __nv_cvt_float2_to_fp4x2(const float2 x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
将输入向量中的两个
single精度数字(打包在float2x中)转换为两个fp4类型值的向量,使用指定的舍入模式并对超出范围的值进行饱和处理。将输入向量
x转换为由fp4_interpretation参数指定类型的两个fp4值组成的向量,使用rounding参数指定的舍入模式。超出范围的大数值会饱和至相同符号的MAXNORM值。NaN输入值将转换为正MAXNORM。- Returns
-
__nv_fp4x2_storage_t值保存转换的结果。
-
__host__ __device__ __nv_fp4_storage_t __nv_cvt_float_to_fp4(const float x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
使用指定的舍入模式将输入的
single精度x转换为请求类型的fp4,并对超出范围的值进行饱和处理。将输入
x转换为由fp4_interpretation参数指定类型的fp4格式,并使用rounding参数指定的舍入模式。超出范围的大数值会饱和至相同符号的MAXNORM值。NaN输入值将转换为正MAXNORM。- Returns
-
__nv_fp4_storage_t值保存转换的结果。
-
__host__ __device__ __half_raw __nv_cvt_fp4_to_halfraw(const __nv_fp4_storage_t x, const __nv_fp4_interpretation_t fp4_interpretation)
-
将指定类型的输入
fp4x转换为half精度。将输入
x从fp4类型(由fp4_interpretation参数指定)转换为half精度。- Returns
-
__half_raw值保存转换结果。
-
__host__ __device__ __half2_raw __nv_cvt_fp4x2_to_halfraw2(const __nv_fp4x2_storage_t x, const __nv_fp4_interpretation_t fp4_interpretation)
-
将指定类型的两个
fp4值组成的输入向量转换为打包在__half2_raw结构中的两个half精度值组成的向量。将输入向量
x从由fp4_interpretation参数指定的fp4类型转换为两个half精度值的向量,并以__half2_raw结构返回。- Returns
-
__half2_raw值保存转换结果。
-
__host__ __device__ __nv_fp4x2_storage_t __nv_cvt_halfraw2_to_fp4x2(const __half2_raw x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
将输入向量中两个打包在
__half2_rawx的半精度数转换为两个指定类型的fp4值向量,使用指定的舍入模式并饱和处理超出范围的值。将输入向量
x转换为由fp4_interpretation参数指定类型的两个fp4值向量,使用rounding参数指定的舍入模式。超出范围的大数值会饱和至相同符号的MAXNORM值。NaN输入值将转换为正MAXNORM。- Returns
-
__nv_fp4x2_storage_t值保存转换的结果。
-
__host__ __device__ __nv_fp4_storage_t __nv_cvt_halfraw_to_fp4(const __half_raw x, const __nv_fp4_interpretation_t fp4_interpretation, const enum cudaRoundMode rounding)
-
使用指定的舍入模式将输入的
half精度x转换为请求类型的fp4,并对超出范围的值进行饱和处理。将输入
x转换为由fp4_interpretation参数指定类型的fp4格式,使用rounding参数指定的舍入模式。超出范围的大数值会饱和到相同符号的MAXNORM值。NaN输入值会转换为正的MAXNORM。- Returns
-
__nv_fp4_storage_t值保存转换结果。
1.4.3. 类型定义
-
typedef __nv_fp8_storage_t __nv_fp4_storage_t
-
用于存储
fp4浮点数的8位unsignedinteger类型抽象。
-
typedef __nv_fp8_storage_t __nv_fp4x2_storage_t
-
用于存储
fp4浮点数对的8位unsignedinteger类型抽象。
-
typedef __nv_fp8x2_storage_t __nv_fp4x4_storage_t
-
用于存储
fp4浮点数四元组的16位unsignedinteger类型抽象。