Go to the documentation of this file. 1 #ifndef HALIDE_FLOAT16_H
2 #define HALIDE_FLOAT16_H
41 #ifdef HALIDE_CPP_COMPILER_HAS_FLOAT16
44 memcpy(&data, &value,
sizeof(_Float16));
52 explicit operator float()
const;
54 explicit operator double()
const;
56 explicit operator int()
const;
58 #ifdef HALIDE_CPP_COMPILER_HAS_FLOAT16
60 explicit operator _Float16()
const {
62 memcpy(&result, &data,
sizeof(_Float16));
92 return (*
this = *
this + rhs);
95 return (*
this = *
this - rhs);
98 return (*
this = *
this * rhs);
101 return (*
this = *
this / rhs);
109 return !(*
this == rhs);
114 return (*
this > rhs) || (*
this == rhs);
117 return (*
this < rhs) || (*
this == rhs);
141 static_assert(
sizeof(float16_t) == 2,
"float16_t should occupy two bytes");
188 explicit operator float()
const;
190 explicit operator double()
const;
192 explicit operator int()
const;
219 return (*
this = *
this + rhs);
222 return (*
this = *
this - rhs);
225 return (*
this = *
this * rhs);
228 return (*
this = *
this / rhs);
236 return !(*
this == rhs);
241 return (*
this > rhs) || (*
this == rhs);
244 return (*
this < rhs) || (*
this == rhs);
268 static_assert(
sizeof(bfloat16_t) == 2,
"bfloat16_t should occupy two bytes");
float16_t operator-=(float16_t rhs)
bfloat16_t operator/(bfloat16_t rhs) const
static const uint16_t sign_mask
bool operator==(bfloat16_t rhs) const
Comparison operators.
@ halide_type_bfloat
floating point numbers in the bfloat format
float16_t operator+(float16_t rhs) const
Arithmetic operators.
unsigned __INT16_TYPE__ uint16_t
static float16_t make_nan()
static const bfloat16_t negative_zero
@ halide_type_float
IEEE floating point numbers.
bool operator>=(bfloat16_t rhs) const
bfloat16_t operator-=(bfloat16_t rhs)
static const bfloat16_t zero
static bfloat16_t make_infinity()
static const uint16_t exponent_mask
static float16_t make_zero()
Get a new float16_t that represents a special value.
float16_t operator-() const
Return a new float16_t with a negated sign bit.
static float16_t make_negative_zero()
A runtime tag for a type in the halide type system.
bool operator==(float16_t rhs) const
Comparison operators.
bool operator<=(bfloat16_t rhs) const
static const uint16_t sign_mask
static const uint16_t mantissa_mask
bool operator!=(bfloat16_t rhs) const
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
bool operator<(bfloat16_t rhs) const
static const bfloat16_t infinity
#define HALIDE_ALWAYS_INLINE
bool is_nan() const
Properties.
static bfloat16_t make_from_bits(uint16_t bits)
Get a new bfloat16_t with the given raw bits.
bfloat16_t operator+=(bfloat16_t rhs)
bfloat16_t operator*(bfloat16_t rhs) const
float16_t()=default
Construct a float16_t with the bits initialised to 0.
bfloat16_t()=default
Construct a bfloat16_t with the bits initialised to 0.
bool operator>(bfloat16_t rhs) const
static const bfloat16_t nan
float16_t operator+=(float16_t rhs)
float16_t operator/=(float16_t rhs)
static float16_t make_from_bits(uint16_t bits)
Get a new float16_t with the given raw bits.
bfloat16_t operator*=(bfloat16_t rhs)
float16_t operator*(float16_t rhs) const
static float16_t make_infinity()
Class that provides a type that implements half precision floating point using the bfloat16 format.
static bfloat16_t make_negative_zero()
bfloat16_t operator/=(bfloat16_t rhs)
bool operator>=(float16_t rhs) const
bool operator<=(float16_t rhs) const
uint16_t to_bits() const
Returns the bits that represent this float16_t.
void * memcpy(void *s1, const void *s2, size_t n)
bool is_nan() const
Properties.
static const bfloat16_t negative_infinity
static const uint16_t mantissa_mask
float16_t operator*=(float16_t rhs)
float16_t operator/(float16_t rhs) const
static const uint16_t exponent_mask
static const int mantissa_bits
bfloat16_t operator-() const
Return a new bfloat16_t with a negated sign bit.
static float16_t make_negative_infinity()
static bfloat16_t make_negative_infinity()
Class that provides a type that implements half precision floating point (IEEE754 2008 binary16) in s...
bool operator>(float16_t rhs) const
uint16_t to_bits() const
Returns the bits that represent this bfloat16_t.
bool operator<(float16_t rhs) const
bfloat16_t operator+(bfloat16_t rhs) const
Arithmetic operators.
static bfloat16_t make_nan()
static const int mantissa_bits
static bfloat16_t make_zero()
Get a new bfloat16_t that represents a special value.
bool operator!=(float16_t rhs) const