15.5. __nv_bfloat16

struct __nv_bfloat16

nv_bfloat16 数据类型

该结构实现了用于存储nv_bfloat16浮点数的数据类型。该结构实现了赋值运算符和类型转换。总共使用16位:1位符号位,8位指数位,7位存储尾数。总精度为8位。

公共函数

__nv_bfloat16() = default

默认构造函数。

空的默认构造函数,结果未初始化。

__host__ __device__ inline explicit __nv_bfloat16(const __half f)

使用默认的舍入到最近偶数模式,从__half输入构造__nv_bfloat16

__host__ __device__ inline constexpr __nv_bfloat16(const __nv_bfloat16_raw &hr)

__nv_bfloat16_raw构造。

__host__ __device__ inline __nv_bfloat16(const double f)

使用默认的舍入到最近偶数模式,从double输入构造__nv_bfloat16

__host__ __device__ inline __nv_bfloat16(const float f)

使用默认的舍入到最近偶数模式从float输入构造__nv_bfloat16

__host__ __device__ inline __nv_bfloat16(const long val)

使用默认的舍入到最近偶数模式从long输入构造__nv_bfloat16

__host__ __device__ inline __nv_bfloat16(const unsigned long val)

使用默认的舍入到最近偶数模式,从unsigned long输入构造__nv_bfloat16

__host__ __device__ inline __nv_bfloat16(int val)

使用默认的舍入到最近偶数模式,从int输入构造__nv_bfloat16

__host__ __device__ inline __nv_bfloat16(long long val)

使用默认的舍入到最近偶数模式,从long long输入构造__nv_bfloat16

__host__ __device__ inline __nv_bfloat16(short val)

使用默认的舍入到最近偶数模式,从short整型输入构造__nv_bfloat16

__host__ __device__ inline __nv_bfloat16(unsigned int val)

使用默认的舍入到最近偶数模式,从unsigned int输入构造__nv_bfloat16

__host__ __device__ inline __nv_bfloat16(unsigned long long val)

使用默认的舍入到最近偶数模式,从unsigned long long输入构造__nv_bfloat16

__host__ __device__ inline __nv_bfloat16(unsigned short val)

使用默认的舍入到最近偶数模式,从unsigned short整型输入构造__nv_bfloat16

__host__ __device__ operator __nv_bfloat16_raw() const

类型转换为__nv_bfloat16_raw运算符。

__host__ __device__ operator __nv_bfloat16_raw() volatile const

将类型转换为__nv_bfloat16_raw运算符,输入为volatile

__host__ __device__ inline constexpr operator bool() const

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

输入+0和-0转换为false。非零输入转换为true

__host__ __device__ operator char() const

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

使用向零舍入模式。

检测char类型的有符号性并相应处理,更多细节请参阅有符号和无符号char运算符。

__host__ __device__ operator float() const

类型转换为 float 操作符。

__host__ __device__ operator int() const

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

使用向零舍入模式。

详情请参阅 __bfloat162int_rz(__nv_bfloat16)

__host__ __device__ operator long() const

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

使用向零取整的舍入模式。

__host__ __device__ operator long long() const

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

使用向零舍入模式。

详情请参阅 __bfloat162ll_rz(__nv_bfloat16)

__host__ __device__ operator short() const

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

使用向零舍入模式。

详情请参阅 __bfloat162short_rz(__nv_bfloat16)

__host__ __device__ operator signed char() const

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

使用向零舍入模式。

详情请参阅 __bfloat162char_rz(__nv_bfloat16)

__host__ __device__ operator unsigned char() const

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

使用向零舍入模式。

详情请参阅 __bfloat162uchar_rz(__nv_bfloat16)

__host__ __device__ operator unsigned int() const

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

使用向零舍入模式。

详情请参阅 __bfloat162uint_rz(__nv_bfloat16)

__host__ __device__ operator unsigned long() const

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

使用向零取整的舍入模式。

__host__ __device__ operator unsigned long long() const

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

使用向零舍入模式。

详情请参阅 __bfloat162ull_rz(__nv_bfloat16)

__host__ __device__ operator unsigned short() const

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

使用向零舍入模式。

详情请参阅 __bfloat162ushort_rz(__nv_bfloat16)

__host__ __device__ __nv_bfloat16 &operator=(const __nv_bfloat16_raw &hr)

来自__nv_bfloat16_raw的赋值运算符。

__host__ __device__ volatile __nv_bfloat16 &operator=(const __nv_bfloat16_raw &hr) volatile

__nv_bfloat16_rawvolatile __nv_bfloat16的赋值运算符。

__host__ __device__ __nv_bfloat16 &operator=(const double f)

使用默认的舍入到最近偶数模式,将__nv_bfloat16类型转换为从double输入的赋值运算符。

__host__ __device__ __nv_bfloat16 &operator=(const float f)

使用默认的舍入到最近偶数模式,将__nv_bfloat16类型转换为从float输入的赋值运算符。

__host__ __device__ volatile __nv_bfloat16 &operator=(volatile const __nv_bfloat16_raw &hr) volatile

volatile __nv_bfloat16_rawvolatile __nv_bfloat16的赋值运算符。

__host__ __device__ __nv_bfloat16 &operator=(int val)

int类型转换的赋值运算符,使用默认的向最近偶数舍入模式。

__host__ __device__ __nv_bfloat16 &operator=(long long val)

long long赋值运算符进行类型转换,使用默认的向最近偶数舍入模式。

__host__ __device__ __nv_bfloat16 &operator=(short val)

short类型转换的赋值运算符,使用默认的向最近偶数舍入模式。

__host__ __device__ __nv_bfloat16 &operator=(unsigned int val)

unsigned int赋值操作符进行类型转换,使用默认的向最近偶数舍入模式。

__host__ __device__ __nv_bfloat16 &operator=(unsigned long long val)

unsigned long long类型转换的赋值运算符,使用默认的向最近偶数舍入模式。

__host__ __device__ __nv_bfloat16 &operator=(unsigned short val)

unsigned short类型转换的赋值运算符,使用默认的向最近偶数舍入模式。