33 operator float()
const
48 return m_Value == r.
Val();
71 const uint32_t* u32 =
reinterpret_cast<const uint32_t*
>(&v);
72 uint16_t u16 =
static_cast<uint16_t
>(*u32 >> 16u);
74 const uint16_t lsb = u16 & 0x0001;
76 const uint16_t
error =
static_cast<uint16_t
>((*u32 & 0x0000FFFF));
77 if ((
error > 0x8000 || (
error == 0x8000 && lsb == 1)))
88 const uint32_t u32 =
static_cast<uint32_t
>(m_Value << 16u);
90 static_assert(
sizeof u32 ==
sizeof f32,
"");
91 std::memcpy(&f32, &u32,
sizeof u32);
102 uint16_t max = 0x7F7F;
108 uint16_t nan = 0x7FC0;
114 uint16_t infVal = 0x7F80;
124 os << b.
ToFloat32() <<
"(0x" << std::hex << b.
Val() <<
")";
BFloat16(const BFloat16 &v)=default
BFloat16 & operator=(float v)
static BFloat16 Float32ToBFloat16(const float v)
BFloat16 & operator=(const BFloat16 &other)=default
bool operator==(const BFloat16 &r) const
Copyright (c) 2021 ARM Limited and Contributors.
std::ostream & operator<<(std::ostream &os, const std::vector< Compute > &compute)
Deprecated function that will be removed together with the Compute enum.