3.9. FP8 转换和数据移动

要使用这些函数,请在您的程序中包含头文件 cuda_fp8.h

枚举

__nv_fp8_interpretation_t

枚举将 8 位值作为 fp8 类型引用时可能的解释。

__nv_saturation_t

枚举执行到 fp8 目标类型的窄化转换时适用的模式。

函数

__host__ __device__ __nv_fp8x2_storage_t __nv_cvt_bfloat162raw_to_e8m0x2(const __nv_bfloat162_raw x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding)

将一对 bfloat16 值转换为一对 e8m0 类型的比例因子。

__host__ __device__ __nv_fp8x2_storage_t __nv_cvt_bfloat16raw2_to_fp8x2(const __nv_bfloat162_raw x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

将打包在 __nv_bfloat162_raw x 中的两个 nv_bfloat16 精度数字的输入向量转换为使用舍入到最近偶数和请求的饱和模式的请求类型的两个 fp8 类型值的向量。

__host__ __device__ __nv_fp8_storage_t __nv_cvt_bfloat16raw_to_e8m0(const __nv_bfloat16_raw x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding)

bfloat16 输入转换为 e8m0 类型的比例因子。

__host__ __device__ __nv_fp8_storage_t __nv_cvt_bfloat16raw_to_fp8(const __nv_bfloat16_raw x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

nv_bfloat16 精度 x 转换为使用舍入到最近偶数和请求的饱和模式的请求类型的 fp8 类型。

__host__ __device__ __nv_fp8x2_storage_t __nv_cvt_double2_to_e8m0x2(const double2 x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding)

将一对 double 值转换为一对 e8m0 类型的比例因子。

__host__ __device__ __nv_fp8x2_storage_t __nv_cvt_double2_to_fp8x2(const double2 x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

将打包在 double2 x 中的两个 double 精度数字的输入向量转换为使用舍入到最近偶数和请求的饱和模式的请求类型的两个 fp8 类型值的向量。

__host__ __device__ __nv_fp8_storage_t __nv_cvt_double_to_e8m0(const double x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding)

double 值输入转换为 e8m0 类型的比例因子。

__host__ __device__ __nv_fp8_storage_t __nv_cvt_double_to_fp8(const double x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

double 精度 x 转换为使用舍入到最近偶数和请求的饱和模式的请求类型的 fp8 类型。

__host__ __device__ __nv_bfloat16_raw __nv_cvt_e8m0_to_bf16raw(const __nv_fp8_storage_t x)

e8m0 类型的输入比例因子值转换为 bfloat16

__host__ __device__ __nv_bfloat162_raw __nv_cvt_e8m0x2_to_bf162raw(const __nv_fp8x2_storage_t x)

将一对 e8m0 类型的输入比例因子转换为一对 bfloat16 值。

__host__ __device__ __nv_fp8x2_storage_t __nv_cvt_float2_to_e8m0x2(const float2 x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding)

将一对 float 值转换为一对 e8m0 类型的比例因子。

__host__ __device__ __nv_fp8x2_storage_t __nv_cvt_float2_to_fp8x2(const float2 x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

将打包在 float2 x 中的两个 single 精度数字的输入向量转换为使用舍入到最近偶数和请求的饱和模式的请求类型的两个 fp8 类型值的向量。

__host__ __device__ __nv_fp8_storage_t __nv_cvt_float_to_e8m0(const float x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding)

float 值输入转换为 e8m0 类型的比例因子。

__host__ __device__ __nv_fp8_storage_t __nv_cvt_float_to_fp8(const float x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

single 精度 x 转换为使用舍入到最近偶数和请求的饱和模式的请求类型的 fp8 类型。

__host__ __device__ __half_raw __nv_cvt_fp8_to_halfraw(const __nv_fp8_storage_t x, const __nv_fp8_interpretation_t fp8_interpretation)

将指定类型的输入 fp8 x 转换为 half 精度。

__host__ __device__ __half2_raw __nv_cvt_fp8x2_to_halfraw2(const __nv_fp8x2_storage_t x, const __nv_fp8_interpretation_t fp8_interpretation)

将指定类型的两个 fp8 值的输入向量转换为打包在 __half2_raw 结构体中的两个 half 精度值的向量。

__host__ __device__ __nv_fp8x2_storage_t __nv_cvt_halfraw2_to_fp8x2(const __half2_raw x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

将打包在 __half2_raw x 中的两个 half 精度数字的输入向量转换为使用舍入到最近偶数和请求的饱和模式的请求类型的两个 fp8 类型值的向量。

__host__ __device__ __nv_fp8_storage_t __nv_cvt_halfraw_to_fp8(const __half_raw x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

half 精度 x 转换为使用舍入到最近偶数和请求的饱和模式的请求类型的 fp8 类型。

__host__ __device__ __nv_fp8_e4m3::__nv_fp8_e4m3(const int val)

int 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e4m3::__nv_fp8_e4m3(const unsigned long long int val)

unsigned long long int 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e4m3::__nv_fp8_e4m3(const __nv_bfloat16 f)

__nv_bfloat16 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e4m3::__nv_fp8_e4m3(const long int val)

long int 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e4m3::__nv_fp8_e4m3(const long long int val)

long long int 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__nv_fp8_e4m3::__nv_fp8_e4m3()=default

默认构造函数。

__host__ __device__ __nv_fp8_e4m3::__nv_fp8_e4m3(const unsigned short int val)

unsigned short int 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e4m3::__nv_fp8_e4m3(const float f)

float 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e4m3::__nv_fp8_e4m3(const __half f)

__half 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e4m3::__nv_fp8_e4m3(const unsigned long int val)

unsigned long int 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e4m3::__nv_fp8_e4m3(const double f)

double 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e4m3::__nv_fp8_e4m3(const short int val)

short int 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e4m3::__nv_fp8_e4m3(const unsigned int val)

unsigned int 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e4m3::operator __half() const

__half 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e4m3::operator __nv_bfloat16() const

__nv_bfloat16 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e4m3::operator bool() const

bool 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e4m3::operator char() const

到实现定义的 char 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e4m3::operator double() const

double 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e4m3::operator float() const

float 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e4m3::operator int() const

int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e4m3::operator long int() const

long int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e4m3::operator long long int() const

long long int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e4m3::operator short int() const

short int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e4m3::operator signed char() const

signed char 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e4m3::operator unsigned char() const

unsigned char 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e4m3::operator unsigned int() const

unsigned int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e4m3::operator unsigned long int() const

unsigned long int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e4m3::operator unsigned long long int() const

unsigned long long int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e4m3::operator unsigned short int() const

unsigned short int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::__nv_fp8_e5m2(const __half f)

__half 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e5m2::__nv_fp8_e5m2(const long long int val)

long long int 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e5m2::__nv_fp8_e5m2(const unsigned int val)

unsigned int 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e5m2::__nv_fp8_e5m2(const float f)

float 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e5m2::__nv_fp8_e5m2(const unsigned short int val)

unsigned short int 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__nv_fp8_e5m2::__nv_fp8_e5m2()=default

默认构造函数。

__host__ __device__ __nv_fp8_e5m2::__nv_fp8_e5m2(const int val)

int 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e5m2::__nv_fp8_e5m2(const long int val)

long int 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e5m2::__nv_fp8_e5m2(const double f)

double 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e5m2::__nv_fp8_e5m2(const unsigned long int val)

unsigned long int 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e5m2::__nv_fp8_e5m2(const short int val)

short int 数据类型构造。

__host__ __device__ __nv_fp8_e5m2::__nv_fp8_e5m2(const __nv_bfloat16 f)

__nv_bfloat16 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e5m2::__nv_fp8_e5m2(const unsigned long long int val)

unsigned long long int 数据类型构造,依赖于超出范围值的 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8_e5m2::operator __half() const

__half 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::operator __nv_bfloat16() const

__nv_bfloat16 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::operator bool() const

bool 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::operator char() const

到实现定义的 char 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::operator double() const

double 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::operator float() const

float 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::operator int() const

int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::operator long int() const

long int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::operator long long int() const

long long int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::operator short int() const

short int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::operator signed char() const

signed char 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::operator unsigned char() const

unsigned char 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::operator unsigned int() const

unsigned int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::operator unsigned long int() const

unsigned long int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::operator unsigned long long int() const

unsigned long long int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e5m2::operator unsigned short int() const

unsigned short int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::__nv_fp8_e8m0(const long int val)

long int 数据类型构造,依赖于 cudaRoundZero 舍入。

__host__ __device__ __nv_fp8_e8m0::__nv_fp8_e8m0(const int val)

int 数据类型构造,依赖于 cudaRoundZero 舍入。

__nv_fp8_e8m0::__nv_fp8_e8m0()=default

默认构造函数。

__host__ __device__ __nv_fp8_e8m0::__nv_fp8_e8m0(const unsigned int val)

unsigned int 数据类型构造,依赖于 cudaRoundZero 舍入。

__host__ __device__ __nv_fp8_e8m0::__nv_fp8_e8m0(const float f)

float 数据类型构造,对于大的输入值,依赖于 __NV_SATFINITE 行为,对于舍入,依赖于 cudaRoundZero

__host__ __device__ __nv_fp8_e8m0::__nv_fp8_e8m0(const unsigned long long int val)

unsigned long long int 数据类型构造,依赖于 cudaRoundZero 舍入。

__host__ __device__ __nv_fp8_e8m0::__nv_fp8_e8m0(const double f)

double 数据类型构造,对于大的输入值,依赖于 __NV_SATFINITE 行为,对于舍入,依赖于 cudaRoundZero

__host__ __device__ __nv_fp8_e8m0::__nv_fp8_e8m0(const __half f)

__half 数据类型构造,对于大的输入值,依赖于 __NV_SATFINITE 行为,对于舍入,依赖于 cudaRoundZero

__host__ __device__ __nv_fp8_e8m0::__nv_fp8_e8m0(const __nv_bfloat16 f)

__nv_bfloat16 数据类型构造,对于大的输入值,依赖于 __NV_SATFINITE 行为,对于舍入,依赖于 cudaRoundZero

__host__ __device__ __nv_fp8_e8m0::__nv_fp8_e8m0(const unsigned long int val)

unsigned long int 数据类型构造,依赖于 cudaRoundZero 舍入。

__host__ __device__ __nv_fp8_e8m0::__nv_fp8_e8m0(const unsigned short int val)

unsigned short int 数据类型构造,依赖于 cudaRoundZero 舍入。

__host__ __device__ __nv_fp8_e8m0::__nv_fp8_e8m0(const long long int val)

long long int 数据类型构造,依赖于 cudaRoundZero 舍入。

__host__ __device__ __nv_fp8_e8m0::__nv_fp8_e8m0(const short int val)

short int 数据类型构造,依赖于 cudaRoundZero 舍入。

__host__ __device__ __nv_fp8_e8m0::operator __half() const

__half 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::operator __nv_bfloat16() const

__nv_bfloat16 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::operator bool() const

bool 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::operator char() const

到实现定义的 char 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::operator double() const

double 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::operator float() const

float 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::operator int() const

int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::operator long int() const

long int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::operator long long int() const

long long int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::operator short int() const

short int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::operator signed char() const

signed char 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::operator unsigned char() const

unsigned char 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::operator unsigned int() const

unsigned int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::operator unsigned long int() const

unsigned long int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::operator unsigned long long int() const

unsigned long long int 数据类型的转换运算符。

__host__ __device__ __nv_fp8_e8m0::operator unsigned short int() const

unsigned short int 数据类型的转换运算符。

__nv_fp8x2_e4m3::__nv_fp8x2_e4m3()=default

默认构造函数。

__host__ __device__ __nv_fp8x2_e4m3::__nv_fp8x2_e4m3(const __nv_bfloat162 f)

__nv_bfloat162 数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x2_e4m3::__nv_fp8x2_e4m3(const double2 f)

double2 数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x2_e4m3::__nv_fp8x2_e4m3(const __half2 f)

__half2 数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x2_e4m3::__nv_fp8x2_e4m3(const float2 f)

float2 数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x2_e4m3::operator __half2() const

转换为 __half2 数据类型的转换运算符。

__host__ __device__ __nv_fp8x2_e4m3::operator float2() const

转换为 float2 数据类型的转换运算符。

__host__ __device__ __nv_fp8x2_e5m2::__nv_fp8x2_e5m2(const __nv_bfloat162 f)

__nv_bfloat162 数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x2_e5m2::__nv_fp8x2_e5m2(const double2 f)

double2 数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x2_e5m2::__nv_fp8x2_e5m2(const __half2 f)

__half2 数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__nv_fp8x2_e5m2::__nv_fp8x2_e5m2()=default

默认构造函数。

__host__ __device__ __nv_fp8x2_e5m2::__nv_fp8x2_e5m2(const float2 f)

float2 数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x2_e5m2::operator __half2() const

转换为 __half2 数据类型的转换运算符。

__host__ __device__ __nv_fp8x2_e5m2::operator float2() const

转换为 float2 数据类型的转换运算符。

__host__ __device__ __nv_fp8x2_e8m0::__nv_fp8x2_e8m0(const __half2 f)

__half2 数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x2_e8m0::__nv_fp8x2_e8m0(const float2 f)

float2 数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x2_e8m0::__nv_fp8x2_e8m0(const __nv_bfloat162 f)

__nv_bfloat162 数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x2_e8m0::__nv_fp8x2_e8m0(const double2 f)

double2 数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__nv_fp8x2_e8m0::__nv_fp8x2_e8m0()=default

默认构造函数。

__host__ __device__ __nv_fp8x2_e8m0::operator __half2() const

转换为 __half2 数据类型的转换运算符。

__host__ __device__ __nv_fp8x2_e8m0::operator __nv_bfloat162() const

转换为 __nv_bfloat162 数据类型的转换运算符。

__host__ __device__ __nv_fp8x2_e8m0::operator float2() const

转换为 float2 数据类型的转换运算符。

__host__ __device__ __nv_fp8x4_e4m3::__nv_fp8x4_e4m3(const __nv_bfloat162 flo, const __nv_bfloat162 fhi)

从一对 __nv_bfloat162 数据类型值构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x4_e4m3::__nv_fp8x4_e4m3(const double4 f)

double4 向量数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__nv_fp8x4_e4m3::__nv_fp8x4_e4m3()=default

默认构造函数。

__host__ __device__ __nv_fp8x4_e4m3::__nv_fp8x4_e4m3(const float4 f)

float4 向量数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x4_e4m3::__nv_fp8x4_e4m3(const __half2 flo, const __half2 fhi)

从一对 __half2 数据类型值构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x4_e4m3::operator float4() const

转换为 float4 向量数据类型的转换运算符。

__nv_fp8x4_e5m2::__nv_fp8x4_e5m2()=default

默认构造函数。

__host__ __device__ __nv_fp8x4_e5m2::__nv_fp8x4_e5m2(const double4 f)

double4 向量数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x4_e5m2::__nv_fp8x4_e5m2(const float4 f)

float4 向量数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x4_e5m2::__nv_fp8x4_e5m2(const __nv_bfloat162 flo, const __nv_bfloat162 fhi)

从一对 __nv_bfloat162 数据类型值构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x4_e5m2::__nv_fp8x4_e5m2(const __half2 flo, const __half2 fhi)

从一对 __half2 数据类型值构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x4_e5m2::operator float4() const

转换为 float4 向量数据类型的转换运算符。

__host__ __device__ __nv_fp8x4_e8m0::__nv_fp8x4_e8m0(const __half2 flo, const __half2 fhi)

从一对 __half2 数据类型值构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x4_e8m0::__nv_fp8x4_e8m0(const float4 f)

float4 向量数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x4_e8m0::__nv_fp8x4_e8m0(const double4 f)

double4 向量数据类型构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__host__ __device__ __nv_fp8x4_e8m0::__nv_fp8x4_e8m0(const __nv_bfloat162 flo, const __nv_bfloat162 fhi)

从一对 __nv_bfloat162 数据类型值构造,对于超出范围的值,依赖于 __NV_SATFINITE 行为。

__nv_fp8x4_e8m0::__nv_fp8x4_e8m0()=default

默认构造函数。

__host__ __device__ __nv_fp8x4_e8m0::operator float4() const

转换为 float4 向量数据类型的转换运算符。

类型定义

__nv_fp8_storage_t

用于 fp8 浮点数存储的 8 位 unsigned integer 类型抽象。

__nv_fp8x2_storage_t

用于存储 fp8 浮点数对的 16 位 unsigned integer 类型抽象。

__nv_fp8x4_storage_t

用于存储 fp8 浮点数四元组的 32 位 unsigned integer 类型抽象。

3.9.1. 枚举

enum __nv_fp8_interpretation_t

枚举将 8 位值作为 fp8 类型引用时可能的解释。

enumerator __NV_E4M3

代表 e4m3 类型的 fp8 数字。

enumerator __NV_E5M2

代表 e5m2 类型的 fp8 数字。

enum __nv_saturation_t

枚举执行到 fp8 目标类型的窄化转换时适用的模式。

enumerator __NV_NOSAT

表示当转换结果超出目标类型范围时,不执行饱和到有限值操作。

注意:对于 e4m3 类型的 fp8 类型,大于目标格式最大可表示有限数的结果将变为 NaN。

enumerator __NV_SATFINITE

表示大于目标格式的最大可表示有限数 MAXNORM 的输入,将舍入到与输入符号相同的 MAXNORM。

3.9.2. 函数

__host__ __device__ __nv_fp8x2_storage_t __nv_cvt_bfloat162raw_to_e8m0x2(const __nv_bfloat162_raw x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding)

将一对 bfloat16 值转换为一对 e8m0 类型的比例因子。

另请参阅

__nv_cvt_bfloat16raw_to_e8m0() 以获取转换的详细信息。

返回值

  • __nv_fp8x2_storage_t 值保存转换结果。

__host__ __device__ __nv_fp8x2_storage_t __nv_cvt_bfloat16raw2_to_fp8x2(const __nv_bfloat162_raw x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

将打包在 __nv_bfloat162_raw x 中的两个 nv_bfloat16 精度数字的输入向量,转换为所需类型的 fp8 类型的两个值的向量,使用舍入到最接近的偶数舍入和请求的饱和模式。

将输入向量 x 转换为由 fp8_interpretation 参数指定的类型的两个 fp8 值的向量,使用舍入到最接近的偶数舍入和由 saturate 参数指定的饱和模式。

返回值

  • __nv_fp8x2_storage_t 值保存转换结果。

__host__ __device__ __nv_fp8_storage_t __nv_cvt_bfloat16raw_to_e8m0(const __nv_bfloat16_raw x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding)

bfloat16 输入转换为 e8m0 类型的比例因子。

输入数字的绝对值被舍入到最接近的 2 的幂,方向由 rounding 参数指定。小于最小可表示目标格式数字 2^-127 的舍入结果将被裁剪为 2^-127。大于最大可表示目标格式数字 2^127 的结果,如果 saturate 等于 __NV_SATFINITE,则裁剪为 2^127,否则转换为 NaNNaN 输入转换为 NaN 输出,在目标格式中编码为 0xFF

返回值

  • __nv_fp8_storage_t 值保存转换结果。

__host__ __device__ __nv_fp8_storage_t __nv_cvt_bfloat16raw_to_fp8(const __nv_bfloat16_raw x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

nv_bfloat16 精度 x 转换为使用舍入到最近偶数和请求的饱和模式的请求类型的 fp8 类型。

将输入 x 转换为由 fp8_interpretation 参数指定的类型的 fp8 类型,使用舍入到最接近的偶数舍入和由 saturate 参数指定的饱和模式。

返回值

  • __nv_fp8_storage_t 值保存转换结果。

__host__ __device__ __nv_fp8x2_storage_t __nv_cvt_double2_to_e8m0x2(const double2 x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding)

将一对 double 值转换为一对 e8m0 类型的比例因子。

另请参阅

__nv_cvt_bfloat16raw_to_e8m0() 以获取转换的详细信息。

返回值

  • __nv_fp8x2_storage_t 值保存转换结果。

__host__ __device__ __nv_fp8x2_storage_t __nv_cvt_double2_to_fp8x2(const double2 x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

将打包在 double2 x 中的两个 double 精度数字的输入向量转换为使用舍入到最近偶数和请求的饱和模式的请求类型的两个 fp8 类型值的向量。

将输入向量 x 转换为由 fp8_interpretation 参数指定的类型的两个 fp8 值的向量,使用舍入到最接近的偶数舍入和由 saturate 参数指定的饱和模式。

返回值

  • __nv_fp8x2_storage_t 值保存转换结果。

__host__ __device__ __nv_fp8_storage_t __nv_cvt_double_to_e8m0(const double x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding)

double 值输入转换为 e8m0 类型的比例因子。

另请参阅

__nv_cvt_bfloat16raw_to_e8m0() 以获取转换的详细信息。

返回值

  • __nv_fp8_storage_t 值保存转换结果。

__host__ __device__ __nv_fp8_storage_t __nv_cvt_double_to_fp8(const double x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

double 精度 x 转换为使用舍入到最近偶数和请求的饱和模式的请求类型的 fp8 类型。

将输入 x 转换为由 fp8_interpretation 参数指定的类型的 fp8 类型,使用舍入到最接近的偶数舍入和由 saturate 参数指定的饱和模式。

返回值

  • __nv_fp8_storage_t 值保存转换结果。

__host__ __device__ __nv_bfloat16_raw __nv_cvt_e8m0_to_bf16raw(const __nv_fp8_storage_t x)

e8m0 类型的输入缩放因子值转换为 bfloat16

输入比例是 2 的精确幂或 NaN 值,也可以在目标格式中表示。

返回值

__host__ __device__ __nv_bfloat162_raw __nv_cvt_e8m0x2_to_bf162raw(const __nv_fp8x2_storage_t x)

将一对 e8m0 类型的输入比例因子转换为一对 bfloat16 值。

返回值

__host__ __device__ __nv_fp8x2_storage_t __nv_cvt_float2_to_e8m0x2(const float2 x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding)

将一对 float 值转换为一对 e8m0 类型的比例因子。

另请参阅

__nv_cvt_bfloat16raw_to_e8m0() 以获取转换的详细信息。

返回值

  • __nv_fp8x2_storage_t 值保存转换结果。

__host__ __device__ __nv_fp8x2_storage_t __nv_cvt_float2_to_fp8x2(const float2 x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

将打包在 float2 x 中的两个 single 精度数字的输入向量转换为使用舍入到最近偶数和请求的饱和模式的请求类型的两个 fp8 类型值的向量。

将输入向量 x 转换为由 fp8_interpretation 参数指定的类型的两个 fp8 值的向量,使用舍入到最接近的偶数舍入和由 saturate 参数指定的饱和模式。

返回值

  • __nv_fp8x2_storage_t 值保存转换结果。

__host__ __device__ __nv_fp8_storage_t __nv_cvt_float_to_e8m0(const float x, const __nv_saturation_t saturate, const enum cudaRoundMode rounding)

float 值输入转换为 e8m0 类型的比例因子。

另请参阅

__nv_cvt_bfloat16raw_to_e8m0() 以获取转换的详细信息。

返回值

  • __nv_fp8_storage_t 值保存转换结果。

__host__ __device__ __nv_fp8_storage_t __nv_cvt_float_to_fp8(const float x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

single 精度 x 转换为使用舍入到最近偶数和请求的饱和模式的请求类型的 fp8 类型。

将输入 x 转换为由 fp8_interpretation 参数指定的类型的 fp8 类型,使用舍入到最接近的偶数舍入和由 saturate 参数指定的饱和模式。

返回值

  • __nv_fp8_storage_t 值保存转换结果。

__host__ __device__ __half_raw __nv_cvt_fp8_to_halfraw(const __nv_fp8_storage_t x, const __nv_fp8_interpretation_t fp8_interpretation)

将指定类型的输入 fp8 x 转换为 half 精度。

将输入 xfp8 类型(类型种类由 fp8_interpretation 参数指定)转换为 half 精度。

返回值

__host__ __device__ __half2_raw __nv_cvt_fp8x2_to_halfraw2(const __nv_fp8x2_storage_t x, const __nv_fp8_interpretation_t fp8_interpretation)

将指定类型的两个 fp8 值组成的输入向量,转换为两个 half 精度值组成的向量,并打包在 __half2_raw 结构中。

将输入向量 xfp8 类型(类型种类由 fp8_interpretation 参数指定)转换为两个 half 精度值组成的向量,并作为 __half2_raw 结构返回。

返回值

__host__ __device__ __nv_fp8x2_storage_t __nv_cvt_halfraw2_to_fp8x2(const __half2_raw x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

将打包在 __half2_raw x 中的两个 half 精度数字组成的输入向量,转换为所需类型的两个 fp8 类型值组成的向量,使用舍入到最近的偶数的方式进行舍入,并应用请求的饱和模式。

将输入向量 x 转换为由 fp8_interpretation 参数指定的类型的两个 fp8 值的向量,使用舍入到最接近的偶数舍入和由 saturate 参数指定的饱和模式。

返回值

  • __nv_fp8x2_storage_t 值保存转换结果。

__host__ __device__ __nv_fp8_storage_t __nv_cvt_halfraw_to_fp8(const __half_raw x, const __nv_saturation_t saturate, const __nv_fp8_interpretation_t fp8_interpretation)

half 精度 x 转换为使用舍入到最近偶数和请求的饱和模式的请求类型的 fp8 类型。

将输入 x 转换为由 fp8_interpretation 参数指定的类型的 fp8 类型,使用舍入到最接近的偶数舍入和由 saturate 参数指定的饱和模式。

返回值

  • __nv_fp8_storage_t 值保存转换结果。

3.9.3. 类型定义

typedef unsigned char __nv_fp8_storage_t

用于 fp8 浮点数存储的 8 位 unsigned integer 类型抽象。

typedef unsigned short int __nv_fp8x2_storage_t

用于存储 fp8 浮点数对的 16 位 unsigned integer 类型抽象。

typedef unsigned int __nv_fp8x4_storage_t

用于存储 fp8 浮点数四元组的 32 位 unsigned integer 类型抽象。