1#ifndef HALIDE_FLOAT16_H
2#define HALIDE_FLOAT16_H
43#ifdef HALIDE_CPP_COMPILER_HAS_FLOAT16
46 memcpy(&data, &value,
sizeof(_Float16));
54 explicit operator float()
const;
56 explicit operator double()
const;
58 explicit operator int()
const;
60#ifdef HALIDE_CPP_COMPILER_HAS_FLOAT16
62 explicit operator _Float16()
const {
64 memcpy(&result, &data,
sizeof(_Float16));
94 return (*
this = *
this + rhs);
97 return (*
this = *
this - rhs);
100 return (*
this = *
this * rhs);
103 return (*
this = *
this / rhs);
111 return !(*
this == rhs);
116 return (*
this > rhs) || (*
this == rhs);
119 return (*
this < rhs) || (*
this == rhs);
143static_assert(
sizeof(
float16_t) == 2,
"float16_t should occupy two bytes");
192 explicit operator float()
const;
194 explicit operator double()
const;
196 explicit operator int()
const;
223 return (*
this = *
this + rhs);
226 return (*
this = *
this - rhs);
229 return (*
this = *
this * rhs);
232 return (*
this = *
this / rhs);
240 return !(*
this == rhs);
245 return (*
this > rhs) || (*
this == rhs);
248 return (*
this < rhs) || (*
this == rhs);
272static_assert(
sizeof(
bfloat16_t) == 2,
"bfloat16_t should occupy two bytes");
This file declares the routines used by Halide internally in its runtime.
@ halide_type_float
IEEE floating point numbers.
@ halide_type_bfloat
floating point numbers in the bfloat format
#define HALIDE_ALWAYS_INLINE
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
unsigned __INT64_TYPE__ uint64_t
signed __INT64_TYPE__ int64_t
unsigned __INT16_TYPE__ uint16_t
void * memcpy(void *s1, const void *s2, size_t n)
Class that provides a type that implements half precision floating point using the bfloat16 format.
bfloat16_t operator-=(bfloat16_t rhs)
bool operator>(bfloat16_t rhs) const
bool operator<=(bfloat16_t rhs) const
static const bfloat16_t zero
bfloat16_t operator-() const
Return a new bfloat16_t with a negated sign bit.
bool operator<(bfloat16_t rhs) const
static const uint16_t exponent_mask
bfloat16_t operator*(bfloat16_t rhs) const
static const uint16_t sign_mask
uint16_t to_bits() const
Returns the bits that represent this bfloat16_t.
static const bfloat16_t infinity
static const uint16_t mantissa_mask
bool operator==(bfloat16_t rhs) const
Comparison operators.
static const bfloat16_t nan
bfloat16_t operator+(bfloat16_t rhs) const
Arithmetic operators.
bfloat16_t operator*=(bfloat16_t rhs)
static const bfloat16_t negative_zero
bfloat16_t operator-(bfloat16_t rhs) const
bfloat16_t(int64_t value)
Construct from a float, double, or int using round-to-nearest-ties-to-even.
bfloat16_t operator/=(bfloat16_t rhs)
bfloat16_t()=default
Construct a bfloat16_t with the bits initialised to 0.
bfloat16_t operator/(bfloat16_t rhs) const
static bfloat16_t make_zero()
Get a new bfloat16_t that represents a special value.
static bfloat16_t make_negative_zero()
static const int mantissa_bits
static bfloat16_t make_infinity()
bfloat16_t(float value)
Construct from a float, double, or int using round-to-nearest-ties-to-even.
static bfloat16_t make_from_bits(uint16_t bits)
Get a new bfloat16_t with the given raw bits.
bfloat16_t(uint64_t value)
Construct from a float, double, or int using round-to-nearest-ties-to-even.
bfloat16_t(int value)
Construct from a float, double, or int using round-to-nearest-ties-to-even.
bool is_nan() const
Properties.
static bfloat16_t make_negative_infinity()
bfloat16_t(double value)
Construct from a float, double, or int using round-to-nearest-ties-to-even.
bool operator!=(bfloat16_t rhs) const
static const bfloat16_t negative_infinity
bfloat16_t operator+=(bfloat16_t rhs)
bool operator>=(bfloat16_t rhs) const
static bfloat16_t make_nan()
Class that provides a type that implements half precision floating point (IEEE754 2008 binary16) in s...
static float16_t make_infinity()
float16_t operator/(float16_t rhs) const
float16_t(double value)
Construct from a float, double, or int using round-to-nearest-ties-to-even.
static const uint16_t sign_mask
float16_t operator+(float16_t rhs) const
Arithmetic operators.
float16_t(int value)
Construct from a float, double, or int using round-to-nearest-ties-to-even.
bool operator>=(float16_t rhs) const
static float16_t make_zero()
Get a new float16_t that represents a special value.
float16_t(uint64_t value)
Construct from a float, double, or int using round-to-nearest-ties-to-even.
uint16_t to_bits() const
Returns the bits that represent this float16_t.
bool operator<(float16_t rhs) const
static const uint16_t mantissa_mask
bool operator==(float16_t rhs) const
Comparison operators.
static float16_t make_negative_zero()
static float16_t make_from_bits(uint16_t bits)
Get a new float16_t with the given raw bits.
float16_t(int64_t value)
Construct from a float, double, or int using round-to-nearest-ties-to-even.
float16_t operator/=(float16_t rhs)
static float16_t make_nan()
float16_t(float value)
Construct from a float, double, or int using round-to-nearest-ties-to-even.
float16_t()=default
Construct a float16_t with the bits initialised to 0.
static const uint16_t exponent_mask
float16_t operator-(float16_t rhs) const
bool is_nan() const
Properties.
static float16_t make_negative_infinity()
static const int mantissa_bits
float16_t operator-=(float16_t rhs)
float16_t operator*(float16_t rhs) const
float16_t operator-() const
Return a new float16_t with a negated sign bit.
bool operator!=(float16_t rhs) const
bool operator<=(float16_t rhs) const
bool operator>(float16_t rhs) const
float16_t operator*=(float16_t rhs)
float16_t operator+=(float16_t rhs)
A runtime tag for a type in the halide type system.