Halide  17.0.2
Halide compiler and libraries
Halide::float16_t Struct Reference

Class that provides a type that implements half precision floating point (IEEE754 2008 binary16) in software. More...

#include <Float16.h>

Public Member Functions

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

Static Public Member Functions

static float16_t make_from_bits (uint16_t bits)
 Get a new float16_t with the given raw bits. More...
 
static float16_t make_zero ()
 Get a new float16_t that represents a special value. More...
 
static float16_t make_negative_zero ()
 Get a new float16_t that represents a special value. More...
 
static float16_t make_infinity ()
 Get a new float16_t that represents a special value. More...
 
static float16_t make_negative_infinity ()
 Get a new float16_t that represents a special value. More...
 
static float16_t make_nan ()
 Get a new float16_t that represents a special value. More...
 

Static Public Attributes

static const int mantissa_bits = 10
 
static const uint16_t sign_mask = 0x8000
 
static const uint16_t exponent_mask = 0x7c00
 
static const uint16_t mantissa_mask = 0x03ff
 

Detailed Description

Class that provides a type that implements half precision floating point (IEEE754 2008 binary16) in software.

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

Definition at line 17 of file Float16.h.

Constructor & Destructor Documentation

◆ float16_t() [1/4]

Halide::float16_t::float16_t ( float  value)
explicit

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

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

◆ float16_t() [2/4]

Halide::float16_t::float16_t ( double  value)
explicit

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

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

◆ float16_t() [3/4]

Halide::float16_t::float16_t ( int  value)
explicit

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

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

◆ float16_t() [4/4]

Halide::float16_t::float16_t ( )
default

Construct a float16_t with the bits initialised to 0.

This represents positive zero.

Member Function Documentation

◆ operator float()

Halide::float16_t::operator float ( ) const
explicit

Cast to float.

◆ operator double()

Halide::float16_t::operator double ( ) const
explicit

Cast to double.

◆ operator int()

Halide::float16_t::operator int ( ) const
explicit

Cast to int.

◆ make_zero()

static float16_t Halide::float16_t::make_zero ( )
static

Get a new float16_t that represents a special value.

◆ make_negative_zero()

static float16_t Halide::float16_t::make_negative_zero ( )
static

Get a new float16_t that represents a special value.

◆ make_infinity()

static float16_t Halide::float16_t::make_infinity ( )
static

Get a new float16_t that represents a special value.

◆ make_negative_infinity()

static float16_t Halide::float16_t::make_negative_infinity ( )
static

Get a new float16_t that represents a special value.

◆ make_nan()

static float16_t Halide::float16_t::make_nan ( )
static

Get a new float16_t that represents a special value.

◆ make_from_bits()

static float16_t Halide::float16_t::make_from_bits ( uint16_t  bits)
static

Get a new float16_t with the given raw bits.

Parameters
bitsThe bits conformant to IEEE754 binary16

◆ operator-() [1/2]

float16_t Halide::float16_t::operator- ( ) const

Return a new float16_t with a negated sign bit.

◆ operator+()

float16_t Halide::float16_t::operator+ ( float16_t  rhs) const

Arithmetic operators.

◆ operator-() [2/2]

float16_t Halide::float16_t::operator- ( float16_t  rhs) const

Arithmetic operators.

◆ operator*()

float16_t Halide::float16_t::operator* ( float16_t  rhs) const

Arithmetic operators.

◆ operator/()

float16_t Halide::float16_t::operator/ ( float16_t  rhs) const

Arithmetic operators.

◆ operator+=()

float16_t Halide::float16_t::operator+= ( float16_t  rhs)
inline

Arithmetic operators.

Definition at line 91 of file Float16.h.

◆ operator-=()

float16_t Halide::float16_t::operator-= ( float16_t  rhs)
inline

Arithmetic operators.

Definition at line 94 of file Float16.h.

◆ operator*=()

float16_t Halide::float16_t::operator*= ( float16_t  rhs)
inline

Arithmetic operators.

Definition at line 97 of file Float16.h.

◆ operator/=()

float16_t Halide::float16_t::operator/= ( float16_t  rhs)
inline

Arithmetic operators.

Definition at line 100 of file Float16.h.

◆ operator==()

bool Halide::float16_t::operator== ( float16_t  rhs) const

Comparison operators.

◆ operator!=()

bool Halide::float16_t::operator!= ( float16_t  rhs) const
inline

Comparison operators.

Definition at line 108 of file Float16.h.

◆ operator>()

bool Halide::float16_t::operator> ( float16_t  rhs) const

Comparison operators.

◆ operator<()

bool Halide::float16_t::operator< ( float16_t  rhs) const

Comparison operators.

◆ operator>=()

bool Halide::float16_t::operator>= ( float16_t  rhs) const
inline

Comparison operators.

Definition at line 113 of file Float16.h.

◆ operator<=()

bool Halide::float16_t::operator<= ( float16_t  rhs) const
inline

Comparison operators.

Definition at line 116 of file Float16.h.

◆ is_nan()

bool Halide::float16_t::is_nan ( ) const

Properties.

◆ is_infinity()

bool Halide::float16_t::is_infinity ( ) const

Properties.

◆ is_negative()

bool Halide::float16_t::is_negative ( ) const

Properties.

◆ is_zero()

bool Halide::float16_t::is_zero ( ) const

Properties.

◆ to_bits()

uint16_t Halide::float16_t::to_bits ( ) const

Returns the bits that represent this float16_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::float16_t::mantissa_bits = 10
static

Definition at line 19 of file Float16.h.

◆ sign_mask

const uint16_t Halide::float16_t::sign_mask = 0x8000
static

Definition at line 20 of file Float16.h.

◆ exponent_mask

const uint16_t Halide::float16_t::exponent_mask = 0x7c00
static

Definition at line 21 of file Float16.h.

◆ mantissa_mask

const uint16_t Halide::float16_t::mantissa_mask = 0x03ff
static

Definition at line 22 of file Float16.h.


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