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

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

#include <GPUORTFloat16.h>

Public Member Functions

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

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

Detailed Description

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

Shared implementation between public and internal classes. CRTP pattern.

Definition at line 46 of file GPUORTFloat16.h.

Constructor & Destructor Documentation

◆ Float16Impl()

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

Member Function Documentation

◆ Abs()

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

Creates an instance that represents absolute value.

Returns
Absolute value

Definition at line 189 of file GPUORTFloat16.h.

◆ AbsImpl()

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

Creates an instance that represents absolute value.

Returns
Absolute value

Definition at line 65 of file GPUORTFloat16.h.

◆ AreZero()

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

◆ IsFinite()

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

Tests if the value is finite.

Returns
true if finite

Definition at line 119 of file GPUORTFloat16.h.

◆ IsInfinity()

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

◆ IsNaN()

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

Tests if the value is NaN.

Returns
true if NaN

Definition at line 110 of file GPUORTFloat16.h.

◆ IsNaNOrZero()

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

◆ IsNegative()

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

Checks if the value is negative.

Returns
true if negative

Definition at line 101 of file GPUORTFloat16.h.

◆ IsNegativeInfinity()

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

Tests if the value represents negative infinity.

Returns
true if negative infinity

Definition at line 137 of file GPUORTFloat16.h.

◆ IsNormal()

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

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

Returns
True if so

Definition at line 165 of file GPUORTFloat16.h.

◆ IsPositiveInfinity()

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

Tests if the value represents positive infinity.

Returns
true if positive infinity

Definition at line 128 of file GPUORTFloat16.h.

◆ IsSubnormal()

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

Tests if the value is subnormal (denormal).

Returns
True if so

Definition at line 177 of file GPUORTFloat16.h.

◆ Negate()

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

Creates a new instance with the sign flipped.

Returns
Flipped sign instance

Definition at line 195 of file GPUORTFloat16.h.

◆ NegateImpl()

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

Creates a new instance with the sign flipped.

Returns
Flipped sign instance

Definition at line 74 of file GPUORTFloat16.h.

◆ operator!=()

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

Definition at line 219 of file GPUORTFloat16.h.

◆ operator<()

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

Definition at line 221 of file GPUORTFloat16.h.

◆ operator==()

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

Definition at line 210 of file GPUORTFloat16.h.

◆ ToFloatImpl()

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

Converts float16 to float.

Returns
float representation of float16 value

Definition at line 319 of file GPUORTFloat16.h.

◆ ToUint16Impl()

template<class Derived >
constexpr uint16_t o2::OrtDataType::Float16Impl< Derived >::ToUint16Impl ( float  v)
inlinestaticconstexprprotectednoexcept

Converts from float to uint16_t float16 representation.

Parameters
v
Returns

Definition at line 270 of file GPUORTFloat16.h.

Member Data Documentation

◆ kBiasedExponentMask

template<class Derived >
constexpr uint16_t o2::OrtDataType::Float16Impl< Derived >::kBiasedExponentMask = 0x7C00U
staticconstexpr

Definition at line 82 of file GPUORTFloat16.h.

◆ kEpsilonBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::Float16Impl< Derived >::kEpsilonBits = 0x4170U
staticconstexpr

Definition at line 87 of file GPUORTFloat16.h.

◆ kMaxValueBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::Float16Impl< Derived >::kMaxValueBits = 0x7BFFU
staticconstexpr

Definition at line 89 of file GPUORTFloat16.h.

◆ kMinusOneBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::Float16Impl< Derived >::kMinusOneBits = 0xBC00U
staticconstexpr

Definition at line 91 of file GPUORTFloat16.h.

◆ kMinValueBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::Float16Impl< Derived >::kMinValueBits = 0xFBFFU
staticconstexpr

Definition at line 88 of file GPUORTFloat16.h.

◆ kNegativeInfinityBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::Float16Impl< Derived >::kNegativeInfinityBits = 0xFC00U
staticconstexpr

Definition at line 84 of file GPUORTFloat16.h.

◆ kNegativeQNaNBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::Float16Impl< Derived >::kNegativeQNaNBits = 0xFE00U
staticconstexpr

Definition at line 86 of file GPUORTFloat16.h.

◆ kOneBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::Float16Impl< Derived >::kOneBits = 0x3C00U
staticconstexpr

Definition at line 90 of file GPUORTFloat16.h.

◆ kPositiveInfinityBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::Float16Impl< Derived >::kPositiveInfinityBits = 0x7C00U
staticconstexpr

Definition at line 83 of file GPUORTFloat16.h.

◆ kPositiveQNaNBits

template<class Derived >
constexpr uint16_t o2::OrtDataType::Float16Impl< Derived >::kPositiveQNaNBits = 0x7E00U
staticconstexpr

Definition at line 85 of file GPUORTFloat16.h.

◆ kSignMask

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

Definition at line 81 of file GPUORTFloat16.h.

◆ val

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

Definition at line 93 of file GPUORTFloat16.h.


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