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");
bool operator>=(bfloat16_t rhs) const
Comparison operators.
static float16_t make_from_bits(uint16_t bits)
Get a new float16_t with the given raw bits.
static const int mantissa_bits
static const uint16_t exponent_mask
float16_t operator-() const
Return a new float16_t with a negated sign bit.
float16_t operator+(float16_t rhs) const
Arithmetic operators.
static float16_t make_negative_zero()
Get a new float16_t that represents a special value.
static float16_t make_nan()
Get a new float16_t that represents a special value.
bool is_infinity() const
Properties.
static bfloat16_t make_nan()
Get a new bfloat16_t that represents a special value.
static const uint16_t sign_mask
static bfloat16_t make_zero()
Get a new bfloat16_t that represents a special value.
static const uint16_t sign_mask
bool is_negative() const
Properties.
bfloat16_t operator/(bfloat16_t rhs) const
Arithmetic operators.
void * memcpy(void *s1, const void *s2, size_t n)
IEEE floating point numbers.
static const uint16_t mantissa_mask
bool is_negative() const
Properties.
static bfloat16_t make_infinity()
Get a new bfloat16_t that represents a special value.
bool operator<=(bfloat16_t rhs) const
Comparison operators.
bool is_zero() const
Properties.
bool operator<(bfloat16_t rhs) const
Comparison operators.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline, and contains methods to using Halide's bounds tools to query properties of it.
bool operator==(float16_t rhs) const
Comparison operators.
static const bfloat16_t negative_zero
bfloat16_t operator-=(bfloat16_t rhs)
Arithmetic operators.
Class that provides a type that implements half precision floating point using the bfloat16 format...
bool is_zero() const
Properties.
static const bfloat16_t zero
bool operator!=(float16_t rhs) const
Comparison operators.
bool is_infinity() const
Properties.
float16_t operator-=(float16_t rhs)
Arithmetic operators.
float16_t()=default
Construct a float16_t with the bits initialised to 0.
static const bfloat16_t infinity
float16_t operator*=(float16_t rhs)
Arithmetic operators.
float16_t operator*(float16_t rhs) const
Arithmetic operators.
bool operator>(bfloat16_t rhs) const
Comparison operators.
float16_t operator/=(float16_t rhs)
Arithmetic operators.
Class that provides a type that implements half precision floating point (IEEE754 2008 binary16) in s...
This file declares the routines used by Halide internally in its runtime.
bool operator!=(bfloat16_t rhs) const
Comparison operators.
bfloat16_t operator+=(bfloat16_t rhs)
Arithmetic operators.
static const bfloat16_t nan
bfloat16_t operator/=(bfloat16_t rhs)
Arithmetic operators.
bfloat16_t operator*(bfloat16_t rhs) const
Arithmetic operators.
bfloat16_t operator*=(bfloat16_t rhs)
Arithmetic operators.
static float16_t make_infinity()
Get a new float16_t that represents a special value.
#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.
A runtime tag for a type in the halide type system.
bfloat16_t()=default
Construct a bfloat16_t with the bits initialised to 0.
static bfloat16_t make_negative_zero()
Get a new bfloat16_t that represents a special value.
static const uint16_t exponent_mask
static float16_t make_negative_infinity()
Get a new float16_t that represents a special value.
float16_t operator+=(float16_t rhs)
Arithmetic operators.
unsigned __INT16_TYPE__ uint16_t
bfloat16_t operator-() const
Return a new bfloat16_t with a negated sign bit.
floating point numbers in the bfloat format
bool operator<(float16_t rhs) const
Comparison operators.
bfloat16_t operator+(bfloat16_t rhs) const
Arithmetic operators.
bool operator>=(float16_t rhs) const
Comparison operators.
bool operator>(float16_t rhs) const
Comparison operators.
static float16_t make_zero()
Get a new float16_t that represents a special value.
bool is_nan() const
Properties.
static bfloat16_t make_negative_infinity()
Get a new bfloat16_t that represents a special value.
static const uint16_t mantissa_mask
uint16_t to_bits() const
Returns the bits that represent this bfloat16_t.
static const int mantissa_bits
static const bfloat16_t negative_infinity
bool operator==(bfloat16_t rhs) const
Comparison operators.
bool operator<=(float16_t rhs) const
Comparison operators.
uint16_t to_bits() const
Returns the bits that represent this float16_t.
float16_t operator/(float16_t rhs) const
Arithmetic operators.