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

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

#include <onnxruntime_float16.h>

Public Member Functions

 BFloat16Impl ()=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...
 

Static Public Member Functions

static bool AreZero (const BFloat16Impl &lhs, const BFloat16Impl &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 = 0x7F80U
 
static constexpr uint16_t kPositiveInfinityBits = 0x7F80U
 
static constexpr uint16_t kNegativeInfinityBits = 0xFF80U
 
static constexpr uint16_t kPositiveQNaNBits = 0x7FC1U
 
static constexpr uint16_t kNegativeQNaNBits = 0xFFC1U
 
static constexpr uint16_t kSignaling_NaNBits = 0x7F80U
 
static constexpr uint16_t kEpsilonBits = 0x0080U
 
static constexpr uint16_t kMinValueBits = 0xFF7FU
 
static constexpr uint16_t kMaxValueBits = 0x7F7FU
 
static constexpr uint16_t kRoundToNearest = 0x7FFFU
 
static constexpr uint16_t kOneBits = 0x3F80U
 
static constexpr uint16_t kMinusOneBits = 0xBF80U
 

Protected Member Functions

float ToFloatImpl () const noexcept
 Converts bfloat16 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 uint16_t ToUint16Impl (float v) noexcept
 Converts from float to uint16_t float16 representation More...
 

Detailed Description

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

Shared implementation between public and internal classes. CRTP pattern.

Definition at line 328 of file onnxruntime_float16.h.

Constructor & Destructor Documentation

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

Member Function Documentation

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

Creates an instance that represents absolute value.

Returns
Absolute value

Definition at line 462 of file onnxruntime_float16.h.

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

Creates an instance that represents absolute value.

Returns
Absolute value

Definition at line 347 of file onnxruntime_float16.h.

template<class Derived>
static bool onnxruntime_float16::BFloat16Impl< Derived >::AreZero ( const BFloat16Impl< Derived > &  lhs,
const BFloat16Impl< 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 478 of file onnxruntime_float16.h.

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

Tests if the value is finite

Returns
true if finite

Definition at line 399 of file onnxruntime_float16.h.

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

Tests if the value is either positive or negative infinity.

Returns
True if absolute value is infinity

Definition at line 423 of file onnxruntime_float16.h.

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

Tests if the value is NaN

Returns
true if NaN

Definition at line 391 of file onnxruntime_float16.h.

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

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

Returns
True if NaN or zero.

Definition at line 431 of file onnxruntime_float16.h.

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

Checks if the value is negative

Returns
true if negative

Definition at line 383 of file onnxruntime_float16.h.

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

Tests if the value represents negative infinity

Returns
true if negative infinity

Definition at line 415 of file onnxruntime_float16.h.

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

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

Returns
True if so

Definition at line 440 of file onnxruntime_float16.h.

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

Tests if the value represents positive infinity.

Returns
true if positive infinity

Definition at line 407 of file onnxruntime_float16.h.

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

Tests if the value is subnormal (denormal).

Returns
True if so

Definition at line 451 of file onnxruntime_float16.h.

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

Creates a new instance with the sign flipped.

Returns
Flipped sign instance

Definition at line 468 of file onnxruntime_float16.h.

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

Creates a new instance with the sign flipped.

Returns
Flipped sign instance

Definition at line 355 of file onnxruntime_float16.h.

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

Converts bfloat16 to float

Returns
float representation of bfloat16 value

Definition at line 519 of file onnxruntime_float16.h.

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

Converts from float to uint16_t float16 representation

Parameters
v
Returns

Definition at line 487 of file onnxruntime_float16.h.

Member Data Documentation

template<class Derived>
constexpr uint16_t onnxruntime_float16::BFloat16Impl< Derived >::kBiasedExponentMask = 0x7F80U
static

Definition at line 362 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::BFloat16Impl< Derived >::kEpsilonBits = 0x0080U
static

Definition at line 368 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::BFloat16Impl< Derived >::kMaxValueBits = 0x7F7FU
static

Definition at line 370 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::BFloat16Impl< Derived >::kMinusOneBits = 0xBF80U
static

Definition at line 373 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::BFloat16Impl< Derived >::kMinValueBits = 0xFF7FU
static

Definition at line 369 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::BFloat16Impl< Derived >::kNegativeInfinityBits = 0xFF80U
static

Definition at line 364 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::BFloat16Impl< Derived >::kNegativeQNaNBits = 0xFFC1U
static

Definition at line 366 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::BFloat16Impl< Derived >::kOneBits = 0x3F80U
static

Definition at line 372 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::BFloat16Impl< Derived >::kPositiveInfinityBits = 0x7F80U
static

Definition at line 363 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::BFloat16Impl< Derived >::kPositiveQNaNBits = 0x7FC1U
static

Definition at line 365 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::BFloat16Impl< Derived >::kRoundToNearest = 0x7FFFU
static

Definition at line 371 of file onnxruntime_float16.h.

template<class Derived>
constexpr uint16_t onnxruntime_float16::BFloat16Impl< Derived >::kSignaling_NaNBits = 0x7F80U
static

Definition at line 367 of file onnxruntime_float16.h.

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

Definition at line 361 of file onnxruntime_float16.h.

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

Definition at line 375 of file onnxruntime_float16.h.


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