HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Ort::BFloat16_t Struct Reference

bfloat16 (Brain Floating Point) data type More...

#include <onnxruntime_cxx_api.h>

+ Inheritance diagram for Ort::BFloat16_t:

Public Types

using Base = onnxruntime_float16::BFloat16Impl< BFloat16_t >
 

Public Member Functions

 BFloat16_t ()=default
 
 BFloat16_t (float v) noexcept
 __ctor from float. Float is converted into bfloat16 16-bit representation. More...
 
float ToFloat () const noexcept
 Converts bfloat16 to float More...
 
 operator float () const noexcept
 User defined conversion operator. Converts BFloat16_t to float. More...
 
bool operator== (const BFloat16_t &rhs) const noexcept
 
bool operator!= (const BFloat16_t &rhs) const noexcept
 
bool operator< (const BFloat16_t &rhs) const noexcept
 
- Public Member Functions inherited from onnxruntime_float16::BFloat16Impl< BFloat16_t >
 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...
 
BFloat16_t Abs () const noexcept
 Creates an instance that represents absolute value. More...
 
BFloat16_t Negate () const noexcept
 Creates a new instance with the sign flipped. More...
 

Static Public Member Functions

static constexpr BFloat16_t FromBits (uint16_t v) noexcept
 Explicit conversion to uint16_t representation of bfloat16. More...
 
- Static Public Member Functions inherited from onnxruntime_float16::BFloat16Impl< BFloat16_t >
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...
 

Additional Inherited Members

- Public Attributes inherited from onnxruntime_float16::BFloat16Impl< BFloat16_t >
uint16_t val
 
- Static Public Attributes inherited from onnxruntime_float16::BFloat16Impl< BFloat16_t >
static constexpr uint16_t kSignMask
 
static constexpr uint16_t kBiasedExponentMask
 
static constexpr uint16_t kPositiveInfinityBits
 
static constexpr uint16_t kNegativeInfinityBits
 
static constexpr uint16_t kPositiveQNaNBits
 
static constexpr uint16_t kNegativeQNaNBits
 
static constexpr uint16_t kSignaling_NaNBits
 
static constexpr uint16_t kEpsilonBits
 
static constexpr uint16_t kMinValueBits
 
static constexpr uint16_t kMaxValueBits
 
static constexpr uint16_t kRoundToNearest
 
static constexpr uint16_t kOneBits
 
static constexpr uint16_t kMinusOneBits
 
- Protected Member Functions inherited from onnxruntime_float16::BFloat16Impl< BFloat16_t >
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 inherited from onnxruntime_float16::BFloat16Impl< BFloat16_t >
static uint16_t ToUint16Impl (float v) noexcept
 Converts from float to uint16_t float16 representation More...
 

Detailed Description

bfloat16 (Brain Floating Point) data type

This struct is used for converting float to bfloat16 and back so the user could feed inputs and fetch outputs using these type.

The size of the structure should align with uint16_t and one can freely cast uint16_t buffers to/from Ort::BFloat16_t to feed and retrieve data.

// This example demonstrates converion from float to float16
constexpr float values[] = {1.f, 2.f, 3.f, 4.f, 5.f};
std::vector<Ort::BFloat16_t> bfp16_values;
bfp16_values.reserve(std::size(values));
std::transform(std::begin(values), std::end(values), std::back_inserter(bfp16_values),
[](float value) { return Ort::BFloat16_t(value); });

Definition at line 306 of file onnxruntime_cxx_api.h.

Member Typedef Documentation

Constructor & Destructor Documentation

Ort::BFloat16_t::BFloat16_t ( )
default
Ort::BFloat16_t::BFloat16_t ( float  v)
inlineexplicitnoexcept

__ctor from float. Float is converted into bfloat16 16-bit representation.

Parameters
vfloat value

Definition at line 333 of file onnxruntime_cxx_api.h.

Member Function Documentation

static constexpr BFloat16_t Ort::BFloat16_t::FromBits ( uint16_t  v)
inlinestaticnoexcept

Explicit conversion to uint16_t representation of bfloat16.

Parameters
vuint16_t bit representation of bfloat16
Returns
new instance of BFloat16_t

Definition at line 327 of file onnxruntime_cxx_api.h.

Ort::BFloat16_t::operator float ( ) const
inlineexplicitnoexcept

User defined conversion operator. Converts BFloat16_t to float.

Definition at line 420 of file onnxruntime_cxx_api.h.

bool Ort::BFloat16_t::operator!= ( const BFloat16_t rhs) const
inlinenoexcept

Definition at line 425 of file onnxruntime_cxx_api.h.

bool Ort::BFloat16_t::operator< ( const BFloat16_t rhs) const
inlinenoexcept

Definition at line 153 of file onnxruntime_cxx_inline.h.

bool Ort::BFloat16_t::operator== ( const BFloat16_t rhs) const
inlinenoexcept

Definition at line 145 of file onnxruntime_cxx_inline.h.

float Ort::BFloat16_t::ToFloat ( ) const
inlinenoexcept

Converts bfloat16 to float

Returns
float representation of bfloat16 value

Definition at line 339 of file onnxruntime_cxx_api.h.


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