15.18. __nv_fp8_e4m3
-
struct __nv_fp8_e4m3
-
__nv_fp8_e4m3 数据类型
此结构体实现了用于存储
fp8
浮点数的数据类型,类型为e4m3
:包含 1 位符号位、4 位指数位、1 位隐式尾数位和 3 位显式尾数位。此编码不支持无穷大 (Infinity)。NaN 值被限制为 0x7F 和 0xFF。此结构体实现了转换构造函数和运算符。
公共函数
-
__nv_fp8_e4m3() = default
-
默认构造函数。
-
__host__ __device__ inline explicit __nv_fp8_e4m3(const __half f)
-
从
__half
数据类型构造,对于超出范围的值,依赖于__NV_SATFINITE
行为。
-
__host__ __device__ inline explicit __nv_fp8_e4m3(const __nv_bfloat16 f)
-
从
__nv_bfloat16
数据类型构造,对于超出范围的值,依赖于__NV_SATFINITE
行为。
-
__host__ __device__ inline explicit __nv_fp8_e4m3(const double f)
-
从
double
数据类型构造,对于超出范围的值,依赖于__NV_SATFINITE
行为。
-
__host__ __device__ inline explicit __nv_fp8_e4m3(const float f)
-
从
float
数据类型构造,对于超出范围的值,依赖于__NV_SATFINITE
行为。
-
__host__ __device__ inline explicit __nv_fp8_e4m3(const int val)
-
从
int
数据类型构造,对于超出范围的值,依赖于__NV_SATFINITE
行为。
-
__host__ __device__ inline explicit __nv_fp8_e4m3(const long int val)
-
从
long
int
数据类型构造,对于超出范围的值,依赖于__NV_SATFINITE
行为。
-
__host__ __device__ inline explicit __nv_fp8_e4m3(const long long int val)
-
从
long
long
int
数据类型构造,对于超出范围的值,依赖于__NV_SATFINITE
行为。
-
__host__ __device__ inline explicit __nv_fp8_e4m3(const short int val)
-
从
short
int
数据类型构造,对于超出范围的值,依赖于__NV_SATFINITE
行为。
-
__host__ __device__ inline explicit __nv_fp8_e4m3(const unsigned int val)
-
从
unsigned
int
数据类型构造,对于超出范围的值,依赖于__NV_SATFINITE
行为。
-
__host__ __device__ inline explicit __nv_fp8_e4m3(const unsigned long int val)
-
从
unsigned
long
int
数据类型构造,对于超出范围的值,依赖于__NV_SATFINITE
行为。
-
__host__ __device__ inline explicit __nv_fp8_e4m3(const unsigned long long int val)
-
从
unsigned
long
long
int
数据类型构造,对于超出范围的值,依赖于__NV_SATFINITE
行为。
-
__host__ __device__ inline explicit __nv_fp8_e4m3(const unsigned short int val)
-
从
unsigned
short
int
数据类型构造,对于超出范围的值,依赖于__NV_SATFINITE
行为。
-
__host__ __device__ inline explicit operator __nv_bfloat16() const
-
转换为
__nv_bfloat16
数据类型的转换运算符。
-
__host__ __device__ inline explicit operator bool() const
-
转换为
bool
数据类型的转换运算符。+0 和 -0 输入转换为
false
。非零输入转换为true
。
-
__host__ __device__ inline explicit operator char() const
-
转换为实现定义的
char
数据类型的转换运算符。检测
char
类型的有符号性并相应地进行处理,详见有符号和无符号 char 运算符的详细信息。将输入值限制在输出范围内。
NaN
输入转换为zero
。
-
__host__ __device__ inline explicit operator double() const
-
转换为
double
数据类型的转换运算符。
-
__host__ __device__ inline explicit operator float() const
-
转换为
float
数据类型的转换运算符。
-
__host__ __device__ inline explicit operator int() const
-
转换为
int
数据类型的转换运算符。NaN
输入转换为zero
。
-
__host__ __device__ inline explicit operator long int() const
-
转换为
long
int
数据类型的转换运算符。将过大的输入值限制在输出范围内。如果输出类型为 32 位,则
NaN
输入转换为zero
。如果输出类型为 64 位,则NaN
输入转换为0x8000000000000000ULL
。
-
__host__ __device__ inline explicit operator long long int() const
-
转换为
long
long
int
数据类型的转换运算符。NaN
输入转换为0x8000000000000000LL
。
-
__host__ __device__ inline explicit operator short int() const
-
转换为
short
int
数据类型的转换运算符。NaN
输入转换为zero
。
-
__host__ __device__ inline explicit operator signed char() const
-
转换为
signed
char
数据类型的转换运算符。将过大的输入值限制在输出范围内。
NaN
输入转换为zero
。
-
__host__ __device__ inline explicit operator unsigned char() const
-
转换为
unsigned
char
数据类型的转换运算符。将负数和过大的输入值限制在输出范围内。
NaN
输入转换为zero
。
-
__host__ __device__ inline explicit operator unsigned int() const
-
转换为
unsigned
int
数据类型的转换运算符。将负数输入限制为零。
NaN
输入转换为zero
。
-
__host__ __device__ inline explicit operator unsigned long int() const
-
转换为
unsigned
long
int
数据类型的转换运算符。将负数和过大的输入值限制在输出范围内。如果输出类型为 32 位,则
NaN
输入转换为zero
。如果输出类型为 64 位,则NaN
输入转换为0x8000000000000000ULL
。
-
__host__ __device__ inline explicit operator unsigned long long int() const
-
转换为
unsigned
long
long
int
数据类型的转换运算符。将负数输入限制为零。
NaN
输入转换为0x8000000000000000ULL
。
-
__host__ __device__ inline explicit operator unsigned short int() const
-
转换为
unsigned
short
int
数据类型的转换运算符。将负数输入限制为零。
NaN
输入转换为zero
。
公共成员
-
__nv_fp8_storage_t __x
-
存储变量包含
fp8
浮点数据。
-
__nv_fp8_e4m3() = default