HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
onnxruntime_float16::Float16Impl< Derived > Struct Template Reference

Shared implementation between public and internal classes. CRTP pattern. More...

#include <onnxruntime_float16.h>

Public Member Functions

 Float16Impl ()=default
 
bool IsNegative () const noexcept
 Checks if the value is negative More...
 
bool IsNaN () const noexcept
 Tests if the value is NaN More...
 
bool IsFinite () const noexcept
 Tests if the value is finite More...
 
bool IsPositiveInfinity () const noexcept
 Tests if the value represents positive infinity. More...
 
bool IsNegativeInfinity () const noexcept
 Tests if the value represents negative infinity More...
 
bool IsInfinity () const noexcept
 Tests if the value is either positive or negative infinity. More...
 
bool IsNaNOrZero () const noexcept
 Tests if the value is NaN or zero. Useful for comparisons. More...
 
bool IsNormal () const noexcept
 Tests if the value is normal (not zero, subnormal, infinite, or NaN). More...
 
bool IsSubnormal () const noexcept
 Tests if the value is subnormal (denormal). More...
 
Derived Abs () const noexcept
 Creates an instance that represents absolute value. More...
 
Derived Negate () const noexcept
 Creates a new instance with the sign flipped. More...
 
bool operator== (const Float16Impl &rhs) const noexcept
 
bool operator!= (const Float16Impl &rhs) const noexcept
 
bool operator< (const Float16Impl &rhs) const noexcept
 

Static Public Member Functions

static bool AreZero (const Float16Impl &lhs, const Float16Impl &rhs) noexcept
 IEEE defines that positive and negative zero are equal, this gives us a quick equality check for two values by or'ing the private bits together and stripping the sign. They are both zero, and therefore equivalent, if the resulting value is still zero. More...
 

Public Attributes

uint16_t val {0}
 

Static Public Attributes

static constexpr uint16_t kSignMask = 0x8000U
 
static constexpr uint16_t kBiasedExponentMask = 0x7C00U
 
static constexpr uint16_t kPositiveInfinityBits = 0x7C00U
 
static constexpr uint16_t kNegativeInfinityBits = 0xFC00U
 
static constexpr uint16_t kPositiveQNaNBits = 0x7E00U
 
static constexpr uint16_t kNegativeQNaNBits = 0xFE00U
 
static constexpr uint16_t kEpsilonBits = 0x4170U
 
static constexpr uint16_t kMinValueBits = 0xFBFFU
 
static constexpr uint16_t kMaxValueBits = 0x7BFFU
 
static constexpr uint16_t kOneBits = 0x3C00U
 
static constexpr uint16_t kMinusOneBits = 0xBC00U
 

Protected Member Functions

float ToFloatImpl () const noexcept
 Converts float16 to float More...
 
uint16_t AbsImpl () const noexcept
 Creates an instance that represents absolute value. More...
 
uint16_t NegateImpl () const noexcept
 Creates a new instance with the sign flipped. More...
 

Static Protected Member Functions

static constexpr uint16_t ToUint16Impl (float v) noexcept
 Converts from float to uint16_t float16 representation More...
 

Detailed Description

template<class Derived>
struct onnxruntime_float16::Float16Impl< Derived >

Shared implementation between public and internal classes. CRTP pattern.

Definition at line 39 of file onnxruntime_float16.h.

Constructor & Destructor Documentation

template<class Derived>
onnxruntime_float16::Float16Impl< Derived >::Float16Impl ( )
default

Member Function Documentation

template<class Derived>
Derived onnxruntime_float16::Float16Impl< Derived >::Abs ( ) const
inlinenoexcept

Creates an instance that represents absolute value.

Returns
Absolute value

Definition at line 171 of file onnxruntime_float16.h.

template<class Derived>
uint16_t onnxruntime_float16::Float16Impl< Derived >::AbsImpl ( ) const
inlineprotectednoexcept

Creates an instance that represents absolute value.

Returns
Absolute value

Definition at line 58 of file onnxruntime_float16.h.

template<class Derived>
static bool onnxruntime_float16::Float16Impl< Derived >::AreZero ( const Float16Impl< Derived > &  lhs,
const Float16Impl< Derived > &  rhs 
)
inlinestaticnoexcept

IEEE defines that positive and negative zero are equal, this gives us a quick equality check for two values by or'ing the private bits together and stripping the sign. They are both zero, and therefore equivalent, if the resulting value is still zero.

Parameters
lhsfirst value
rhssecond value
Returns
True if both arguments represent zero

Definition at line 187 of file onnxruntime_float16.h.

template<class Derived>
bool onnxruntime_float16::Float16Impl< Derived >::IsFinite ( ) const
inlinenoexcept

Tests if the value is finite

Returns
true if finite

Definition at line 108 of file onnxruntime_float16.h.

template<class Derived>
bool onnxruntime_float16::Float16Impl< Derived >::IsInfinity ( ) const
inlinenoexcept

Tests if the value is either positive or negative infinity.

Returns
True if absolute value is infinity

Definition at line 132 of file onnxruntime_float16.h.

template<class Derived>
bool onnxruntime_float16::Float16Impl< Derived >::IsNaN ( ) const
inlinenoexcept

Tests if the value is NaN

Returns
true if NaN

Definition at line 100 of file onnxruntime_float16.h.

template<class Derived>
bool onnxruntime_float16::Float16Impl< Derived >::IsNaNOrZero ( ) const
inlinenoexcept

Tests if the value is NaN or zero. Useful for comparisons.

Returns
True if NaN or zero.

Definition at line 140 of file onnxruntime_float16.h.

template<class Derived>
bool onnxruntime_float16::Float16Impl< Derived >::IsNegative ( ) const
inlinenoexcept

Checks if the value is negative

Returns
true if negative

Definition at line 92 of file onnxruntime_float16.h.

template<class Derived>
bool onnxruntime_float16::Float16Impl< Derived >::IsNegativeInfinity ( ) const
inlinenoexcept

Tests if the value represents negative infinity

Returns
true if negative infinity

Definition at line 124 of file onnxruntime_float16.h.

template<class Derived>
bool onnxruntime_float16::Float16Impl< Derived >::IsNormal ( ) const
inlinenoexcept

Tests if the value is normal (not zero, subnormal, infinite, or NaN).

Returns
True if so

Definition at line 149 of file onnxruntime_float16.h.

template<class Derived>
bool onnxruntime_float16::Float16Impl< Derived >::IsPositiveInfinity ( ) const
inlinenoexcept

Tests if the value represents positive infinity.

Returns
true if positive infinity

Definition at line 116 of file onnxruntime_float16.h.

template<class Derived>
bool onnxruntime_float16::Float16Impl< Derived >::IsSubnormal ( ) const
inlinenoexcept

Tests if the value is subnormal (denormal).

Returns
True if so

Definition at line 160 of file onnxruntime_float16.h.

template<class Derived>
Derived onnxruntime_float16::Float16Impl< Derived >::Negate ( ) const
inlinenoexcept

Creates a new instance with the sign flipped.

Returns
Flipped sign instance

Definition at line 177 of file onnxruntime_float16.h.

template<class Derived>
uint16_t onnxruntime_float16::Float16Impl< Derived >::NegateImpl ( ) const
inlineprotectednoexcept

Creates a new instance with the sign flipped.

Returns
Flipped sign instance

Definition at line 66 of file onnxruntime_float16.h.

template<class Derived>
bool onnxruntime_float16::Float16Impl< Derived >::operator!= ( const Float16Impl< Derived > &  rhs) const
inlinenoexcept

Definition at line 199 of file onnxruntime_float16.h.

template<class Derived>
bool onnxruntime_float16::Float16Impl< Derived >::operator< ( const Float16Impl< Derived > &  rhs) const
inlinenoexcept

Definition at line 201 of file onnxruntime_float16.h.

template<class Derived>
bool onnxruntime_float16::Float16Impl< Derived >::operator== ( const Float16Impl< Derived > &  rhs) const
inlinenoexcept

Definition at line 191 of file onnxruntime_float16.h.

template<class Derived >
float onnxruntime_float16::Float16Impl< Derived >::ToFloatImpl ( ) const
inlineprotectednoexcept

Converts float16 to float

Returns
float representation of float16 value

Definition at line 296 of file onnxruntime_float16.h.

template<class Derived >
constexpr uint16_t onnxruntime_float16::Float16Impl< Derived >::ToUint16Impl ( float  v)
inlinestaticprotectednoexcept

Converts from float to uint16_t float16 representation

Parameters
v
Returns

Definition at line 248 of file onnxruntime_float16.h.

Member Data Documentation

template<class Derived>
constexpr uint16_t onnxruntime_float16::Float16Impl< Derived >::kBiasedExponentMask = 0x7C00U
static

Definition at line 73 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::Float16Impl< Derived >::kEpsilonBits = 0x4170U
static

Definition at line 78 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::Float16Impl< Derived >::kMaxValueBits = 0x7BFFU
static

Definition at line 80 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::Float16Impl< Derived >::kMinusOneBits = 0xBC00U
static

Definition at line 82 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::Float16Impl< Derived >::kMinValueBits = 0xFBFFU
static

Definition at line 79 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::Float16Impl< Derived >::kNegativeInfinityBits = 0xFC00U
static

Definition at line 75 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::Float16Impl< Derived >::kNegativeQNaNBits = 0xFE00U
static

Definition at line 77 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::Float16Impl< Derived >::kOneBits = 0x3C00U
static

Definition at line 81 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::Float16Impl< Derived >::kPositiveInfinityBits = 0x7C00U
static

Definition at line 74 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::Float16Impl< Derived >::kPositiveQNaNBits = 0x7E00U
static

Definition at line 76 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::Float16Impl< Derived >::kSignMask = 0x8000U
static

Definition at line 72 of file onnxruntime_float16.h.

template<class Derived>
uint16_t onnxruntime_float16::Float16Impl< Derived >::val {0}

Definition at line 84 of file onnxruntime_float16.h.


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