Project
Loading...
Searching...
No Matches
o2::OrtDataType::BFloat16Impl< Derived > Struct Template Reference

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

#include <GPUORTFloat16.h>

Public Member Functions

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

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.
 

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.
 
uint16_t AbsImpl () const noexcept
 Creates an instance that represents absolute value.
 
uint16_t NegateImpl () const noexcept
 Creates a new instance with the sign flipped.
 

Static Protected Member Functions

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

Detailed Description

template<class Derived>
struct o2::OrtDataType::BFloat16Impl< Derived >

Shared implementation between public and internal classes. CRTP pattern.

Definition at line 352 of file GPUORTFloat16.h.

Constructor & Destructor Documentation

◆ BFloat16Impl()

template<class Derived >
o2::OrtDataType::BFloat16Impl< Derived >::BFloat16Impl ( )
default

Member Function Documentation

◆ Abs()

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

Creates an instance that represents absolute value.

Returns
Absolute value

Definition at line 497 of file GPUORTFloat16.h.

◆ AbsImpl()

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

Creates an instance that represents absolute value.

Returns
Absolute value

Definition at line 371 of file GPUORTFloat16.h.

◆ AreZero()

template<class Derived >
static bool o2::OrtDataType::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 513 of file GPUORTFloat16.h.

◆ IsFinite()

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

Tests if the value is finite.

Returns
true if finite

Definition at line 427 of file GPUORTFloat16.h.

◆ IsInfinity()

template<class Derived >
bool o2::OrtDataType::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 454 of file GPUORTFloat16.h.

◆ IsNaN()

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

Tests if the value is NaN.

Returns
true if NaN

Definition at line 418 of file GPUORTFloat16.h.

◆ IsNaNOrZero()

template<class Derived >
bool o2::OrtDataType::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 463 of file GPUORTFloat16.h.

◆ IsNegative()

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

Checks if the value is negative.

Returns
true if negative

Definition at line 409 of file GPUORTFloat16.h.

◆ IsNegativeInfinity()

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

Tests if the value represents negative infinity.

Returns
true if negative infinity

Definition at line 445 of file GPUORTFloat16.h.

◆ IsNormal()

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

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

Returns
True if so

Definition at line 473 of file GPUORTFloat16.h.

◆ IsPositiveInfinity()

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

Tests if the value represents positive infinity.

Returns
true if positive infinity

Definition at line 436 of file GPUORTFloat16.h.

◆ IsSubnormal()

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

Tests if the value is subnormal (denormal).

Returns
True if so

Definition at line 485 of file GPUORTFloat16.h.

◆ Negate()

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

Creates a new instance with the sign flipped.

Returns
Flipped sign instance

Definition at line 503 of file GPUORTFloat16.h.

◆ NegateImpl()

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

Creates a new instance with the sign flipped.

Returns
Flipped sign instance

Definition at line 380 of file GPUORTFloat16.h.

◆ ToFloatImpl()

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

Converts bfloat16 to float.

Returns
float representation of bfloat16 value

Definition at line 557 of file GPUORTFloat16.h.

◆ ToUint16Impl()

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

Converts from float to uint16_t float16 representation.

Parameters
v
Returns

Definition at line 523 of file GPUORTFloat16.h.

Member Data Documentation

◆ kBiasedExponentMask

template<class Derived >
constexpr uint16_t o2::OrtDataType::BFloat16Impl< Derived >::kBiasedExponentMask = 0x7F80U
staticconstexpr

Definition at line 388 of file GPUORTFloat16.h.

◆ kEpsilonBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::BFloat16Impl< Derived >::kEpsilonBits = 0x0080U
staticconstexpr

Definition at line 394 of file GPUORTFloat16.h.

◆ kMaxValueBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::BFloat16Impl< Derived >::kMaxValueBits = 0x7F7FU
staticconstexpr

Definition at line 396 of file GPUORTFloat16.h.

◆ kMinusOneBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::BFloat16Impl< Derived >::kMinusOneBits = 0xBF80U
staticconstexpr

Definition at line 399 of file GPUORTFloat16.h.

◆ kMinValueBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::BFloat16Impl< Derived >::kMinValueBits = 0xFF7FU
staticconstexpr

Definition at line 395 of file GPUORTFloat16.h.

◆ kNegativeInfinityBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::BFloat16Impl< Derived >::kNegativeInfinityBits = 0xFF80U
staticconstexpr

Definition at line 390 of file GPUORTFloat16.h.

◆ kNegativeQNaNBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::BFloat16Impl< Derived >::kNegativeQNaNBits = 0xFFC1U
staticconstexpr

Definition at line 392 of file GPUORTFloat16.h.

◆ kOneBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::BFloat16Impl< Derived >::kOneBits = 0x3F80U
staticconstexpr

Definition at line 398 of file GPUORTFloat16.h.

◆ kPositiveInfinityBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::BFloat16Impl< Derived >::kPositiveInfinityBits = 0x7F80U
staticconstexpr

Definition at line 389 of file GPUORTFloat16.h.

◆ kPositiveQNaNBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::BFloat16Impl< Derived >::kPositiveQNaNBits = 0x7FC1U
staticconstexpr

Definition at line 391 of file GPUORTFloat16.h.

◆ kRoundToNearest

template<class Derived >
constexpr uint16_t o2::OrtDataType::BFloat16Impl< Derived >::kRoundToNearest = 0x7FFFU
staticconstexpr

Definition at line 397 of file GPUORTFloat16.h.

◆ kSignaling_NaNBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::BFloat16Impl< Derived >::kSignaling_NaNBits = 0x7F80U
staticconstexpr

Definition at line 393 of file GPUORTFloat16.h.

◆ kSignMask

template<class Derived >
constexpr uint16_t o2::OrtDataType::BFloat16Impl< Derived >::kSignMask = 0x8000U
staticconstexpr

Definition at line 387 of file GPUORTFloat16.h.

◆ val

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

Definition at line 401 of file GPUORTFloat16.h.


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