Skip to main content

ClikaRT::dtype::bfloat16_t

struct

Header: ClikaRT/compute/scalar_types.h

Truncated fp32 (brain float): 1 sign + 8 exponent + 7 mantissa, bias 127; the top 16 bits of an fp32. Range ±3.39e38 (= fp32), eps 2^-7. 16-bit storage. Conversion from fp32 is round-to-nearest-even; from_truncated drops the low 16 bits without rounding.

Static member functions

from_bits()

static constexpr bfloat16_t from_bits(std::uint16_t b) noexcept

Reinterpret a raw 16-bit encoding without converting.

Declared in ClikaRT/compute/scalar_types.h, line 78

from_truncated()

static bfloat16_t from_truncated(float f) noexcept

Convert from fp32 by truncation (drop the low 16 bits, no rounding).

Declared in ClikaRT/compute/scalar_types.h, line 81

Member functions

bfloat16_t()

constexpr constexpr bfloat16_t() noexcept=default

Declared in ClikaRT/compute/scalar_types.h, line 69

bfloat16_t(float)

explicit bfloat16_t(float f) noexcept

Convert from fp32 (round-to-nearest-even).

Declared in ClikaRT/compute/scalar_types.h, line 72

operator float()

operator float() const noexcept

Convert to fp32 (lossless).

Declared in ClikaRT/compute/scalar_types.h, line 75

Data members

bits

std::uint16_t bits = 0

Raw 16-bit encoding (the storage/ABI form).

Declared in ClikaRT/compute/scalar_types.h, line 67

Friends

operator==

friend bool operator==(bfloat16_t a, bfloat16_t b) noexcept

Compares a and b by dequantized value (IEEE rules; a NaN operand compares false).

Declared in ClikaRT/compute/scalar_types.h, line 83

operator!=

friend bool operator!=(bfloat16_t a, bfloat16_t b) noexcept

Compares a and b by dequantized value (IEEE rules; a NaN operand compares false).

Declared in ClikaRT/compute/scalar_types.h, line 84

operator<

friend bool operator<(bfloat16_t a, bfloat16_t b) noexcept

Compares a and b by dequantized value (IEEE rules; a NaN operand compares false).

Declared in ClikaRT/compute/scalar_types.h, line 85

operator<=

friend bool operator<=(bfloat16_t a, bfloat16_t b) noexcept

Compares a and b by dequantized value (IEEE rules; a NaN operand compares false).

Declared in ClikaRT/compute/scalar_types.h, line 86

operator>

friend bool operator>(bfloat16_t a, bfloat16_t b) noexcept

Compares a and b by dequantized value (IEEE rules; a NaN operand compares false).

Declared in ClikaRT/compute/scalar_types.h, line 87

operator>=

friend bool operator>=(bfloat16_t a, bfloat16_t b) noexcept

Compares a and b by dequantized value (IEEE rules; a NaN operand compares false).

Declared in ClikaRT/compute/scalar_types.h, line 88