1#ifndef HALIDE_FLOAT16_H
2#define HALIDE_FLOAT16_H
41#ifdef HALIDE_CPP_COMPILER_HAS_FLOAT16
52 explicit operator float()
const;
56 explicit operator int()
const;
58#ifdef HALIDE_CPP_COMPILER_HAS_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);
141static_assert(
sizeof(
float16_t) == 2,
"float16_t should occupy two bytes");
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);
268static_assert(
sizeof(
bfloat16_t) == 2,
"bfloat16_t should occupy two bytes");
HALIDE_ALWAYS_INLINE constexpr halide_type_t halide_type_of< Halide::bfloat16_t >()
HALIDE_ALWAYS_INLINE constexpr halide_type_t halide_type_of< Halide::float16_t >()
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,...
Internal::ConstantInterval cast(Type t, const Internal::ConstantInterval &a)
Cast operators for ConstantIntervals.
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 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(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.
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 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.