Halide 22.0.0 Halide compiler and libraries

Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
Halide::bfloat16_t Struct Reference

Class that provides a type that implements half precision floating point using the bfloat16 format. More...

`#include <Float16.h>`

## Public Member Functions
| operator float () const
| Cast to float. More...
| operator double () const
| Cast to double. More...
| operator int () const
| Cast to int. More...
bfloat16_t | operator- () const
| Return a new bfloat16_t with a negated sign bit. More...
bfloat16_t | operator+ (bfloat16_t rhs) const
| Arithmetic operators. More...
bfloat16_t | operator- (bfloat16_t rhs) const
bfloat16_t | operator* (bfloat16_t rhs) const
bfloat16_t | operator/ (bfloat16_t rhs) const
bfloat16_t | operator+= (bfloat16_t rhs)
bfloat16_t | operator-= (bfloat16_t rhs)
bfloat16_t | operator*= (bfloat16_t rhs)
bfloat16_t | operator/= (bfloat16_t rhs)
bool | operator== (bfloat16_t rhs) const
| Comparison operators. More...
bool | operator!= (bfloat16_t rhs) const
bool | operator> (bfloat16_t rhs) const
bool | operator< (bfloat16_t rhs) const
bool | operator>= (bfloat16_t rhs) const
bool | operator<= (bfloat16_t rhs) const
bool | is_nan () const
| Properties. More...
bool | is_infinity () const
bool | is_negative () const
bool | is_zero () const
uint16_t | to_bits () const
| Returns the bits that represent this bfloat16_t. More...
Constructors
| bfloat16_t (float value)
| Construct from a float, double, or int using round-to-nearest-ties-to-even. More...
| bfloat16_t (double value)
| Construct from a float, double, or int using round-to-nearest-ties-to-even. More...
| bfloat16_t (int value)
| Construct from a float, double, or int using round-to-nearest-ties-to-even. More...
| bfloat16_t ()=default
| Construct a bfloat16_t with the bits initialised to 0. More...

## Static Public Member Functions
static bfloat16_t | make_zero ()
| Get a new bfloat16_t that represents a special value. More...
static bfloat16_t | make_negative_zero ()
static bfloat16_t | make_infinity ()
static bfloat16_t | make_negative_infinity ()
static bfloat16_t | make_nan ()
static bfloat16_t | make_from_bits (uint16_t bits)
| Get a new bfloat16_t with the given raw bits. More...

## Static Public Attributes
static const int | mantissa_bits = 7
static const uint16_t | sign_mask = 0x8000
static const uint16_t | exponent_mask = 0x7f80
static const uint16_t | mantissa_mask = 0x007f
static const bfloat16_t | zero
static const bfloat16_t | negative_zero
static const bfloat16_t | infinity
static const bfloat16_t | negative_infinity
static const bfloat16_t | nan

## Detailed Description

Class that provides a type that implements half precision floating point using the bfloat16 format.

This type is enforced to be 16-bits wide and maintains no state other than the raw bits so that it can passed to code that checks a type's size and used for halide_buffer_t allocation.

Definition at line 158 of file Float16.h.

## Constructor & Destructor Documentation

## ◆ bfloat16_t() [1/4]

Halide::bfloat16_t::bfloat16_t | ( | float | value | ) |
| explicit

Construct from a float, double, or int using round-to-nearest-ties-to-even.

Out-of-range values become +/- infinity.

## ◆ bfloat16_t() [2/4]

Halide::bfloat16_t::bfloat16_t | ( | double | value | ) |
| explicit

Construct from a float, double, or int using round-to-nearest-ties-to-even.

Out-of-range values become +/- infinity.

## ◆ bfloat16_t() [3/4]

Halide::bfloat16_t::bfloat16_t | ( | int | value | ) |
| explicit

Construct from a float, double, or int using round-to-nearest-ties-to-even.

Out-of-range values become +/- infinity.

## ◆ bfloat16_t() [4/4]

Halide::bfloat16_t::bfloat16_t | ( |  | ) |
| default

Construct a bfloat16_t with the bits initialised to 0.

This represents positive zero.

## Member Function Documentation

## ◆ operator float()

Halide::bfloat16_t::operator float | ( |  | ) | const
| explicit

Cast to float.

## ◆ operator double()

Halide::bfloat16_t::operator double | ( |  | ) | const
| explicit

Cast to double.

## ◆ operator int()

Halide::bfloat16_t::operator int | ( |  | ) | const
| explicit

Cast to int.

## ◆ make_zero()

static bfloat16_t Halide::bfloat16_t::make_zero | ( |  | ) |
| static

Get a new bfloat16_t that represents a special value.

## ◆ make_negative_zero()

static bfloat16_t Halide::bfloat16_t::make_negative_zero | ( |  | ) |
| static

## ◆ make_infinity()

static bfloat16_t Halide::bfloat16_t::make_infinity | ( |  | ) |
| static

## ◆ make_negative_infinity()

static bfloat16_t Halide::bfloat16_t::make_negative_infinity | ( |  | ) |
| static

## ◆ make_nan()

static bfloat16_t Halide::bfloat16_t::make_nan | ( |  | ) |
| static

## ◆ make_from_bits()

static bfloat16_t Halide::bfloat16_t::make_from_bits | ( | uint16_t | bits | ) |
| static

Get a new bfloat16_t with the given raw bits.

Parameters

  bits | The bits conformant to IEEE754 binary16

## ◆ operator-() [1/2]

bfloat16_t Halide::bfloat16_t::operator- | ( |  | ) | const

Return a new bfloat16_t with a negated sign bit.

## ◆ operator+()

bfloat16_t Halide::bfloat16_t::operator+ | ( | bfloat16_t | rhs | ) | const

Arithmetic operators.

## ◆ operator-() [2/2]

bfloat16_t Halide::bfloat16_t::operator- | ( | bfloat16_t | rhs | ) | const

## ◆ operator*()

bfloat16_t Halide::bfloat16_t::operator* | ( | bfloat16_t | rhs | ) | const

## ◆ operator/()

bfloat16_t Halide::bfloat16_t::operator/ | ( | bfloat16_t | rhs | ) | const

## ◆ operator+=()

bfloat16_t Halide::bfloat16_t::operator+= | ( | bfloat16_t | rhs | ) |
| inline

Definition at line 218 of file Float16.h.

## ◆ operator-=()

bfloat16_t Halide::bfloat16_t::operator-= | ( | bfloat16_t | rhs | ) |
| inline

Definition at line 221 of file Float16.h.

## ◆ operator*=()

bfloat16_t Halide::bfloat16_t::operator*= | ( | bfloat16_t | rhs | ) |
| inline

Definition at line 224 of file Float16.h.

## ◆ operator/=()

bfloat16_t Halide::bfloat16_t::operator/= | ( | bfloat16_t | rhs | ) |
| inline

Definition at line 227 of file Float16.h.

## ◆ operator==()

bool Halide::bfloat16_t::operator== | ( | bfloat16_t | rhs | ) | const

Comparison operators.

## ◆ operator!=()

bool Halide::bfloat16_t::operator!= | ( | bfloat16_t | rhs | ) | const
| inline

Definition at line 235 of file Float16.h.

## ◆ operator>()

bool Halide::bfloat16_t::operator> | ( | bfloat16_t | rhs | ) | const

## ◆ operator<()

bool Halide::bfloat16_t::operator< | ( | bfloat16_t | rhs | ) | const

## ◆ operator>=()

bool Halide::bfloat16_t::operator>= | ( | bfloat16_t | rhs | ) | const
| inline

Definition at line 240 of file Float16.h.

## ◆ operator<=()

bool Halide::bfloat16_t::operator<= | ( | bfloat16_t | rhs | ) | const
| inline

Definition at line 243 of file Float16.h.

## ◆ is_nan()

bool Halide::bfloat16_t::is_nan | ( |  | ) | const

Properties.

## ◆ is_infinity()

bool Halide::bfloat16_t::is_infinity | ( |  | ) | const

## ◆ is_negative()

bool Halide::bfloat16_t::is_negative | ( |  | ) | const

## ◆ is_zero()

bool Halide::bfloat16_t::is_zero | ( |  | ) | const

## ◆ to_bits()

uint16_t Halide::bfloat16_t::to_bits | ( |  | ) | const

Returns the bits that represent this bfloat16_t.

An alternative method to access the bits is to cast a pointer to this instance as a pointer to a uint16_t.

## Member Data Documentation

## ◆ mantissa_bits

const int Halide::bfloat16_t::mantissa_bits = 7
| static

Definition at line 160 of file Float16.h.

## ◆ sign_mask

const uint16_t Halide::bfloat16_t::sign_mask = 0x8000
| static

Definition at line 161 of file Float16.h.

## ◆ exponent_mask

const uint16_t Halide::bfloat16_t::exponent_mask = 0x7f80
| static

Definition at line 162 of file Float16.h.

## ◆ mantissa_mask

const uint16_t Halide::bfloat16_t::mantissa_mask = 0x007f
| static

Definition at line 163 of file Float16.h.

## ◆ zero

const bfloat16_t Halide::bfloat16_t::zero
| static

Definition at line 165 of file Float16.h.

## ◆ negative_zero

const bfloat16_t Halide::bfloat16_t::negative_zero
| static

Definition at line 165 of file Float16.h.

## ◆ infinity

const bfloat16_t Halide::bfloat16_t::infinity
| static

Definition at line 165 of file Float16.h.

## ◆ negative_infinity

const bfloat16_t Halide::bfloat16_t::negative_infinity
| static

Definition at line 165 of file Float16.h.

## ◆ nan

const bfloat16_t Halide::bfloat16_t::nan
| static

Definition at line 165 of file Float16.h.

The documentation for this struct was generated from the following file:

- src/Float16.h