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

IEEE 754 half-precision floating point data type. More...

#include <onnxruntime_cxx_api.h>

+ Inheritance diagram for Ort::Float16_t:

Public Types

using Base = onnxruntime_float16::Float16Impl< Float16_t >
 

Public Member Functions

 Float16_t ()=default
 Default constructor More...
 
 Float16_t (float v) noexcept
 __ctor from float. Float is converted into float16 16-bit representation. More...
 
float ToFloat () const noexcept
 Converts float16 to float More...
 
 operator float () const noexcept
 User defined conversion operator. Converts Float16_t to float. More...
 
- Public Member Functions inherited from onnxruntime_float16::Float16Impl< Float16_t >
 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...
 
Float16_t Abs () const noexcept
 Creates an instance that represents absolute value. More...
 
Float16_t 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 constexpr Float16_t FromBits (uint16_t v) noexcept
 Explicit conversion to uint16_t representation of float16. More...
 
- Static Public Member Functions inherited from onnxruntime_float16::Float16Impl< Float16_t >
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...
 

Additional Inherited Members

- Public Attributes inherited from onnxruntime_float16::Float16Impl< Float16_t >
uint16_t val
 
- Static Public Attributes inherited from onnxruntime_float16::Float16Impl< Float16_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 kEpsilonBits
 
static constexpr uint16_t kMinValueBits
 
static constexpr uint16_t kMaxValueBits
 
static constexpr uint16_t kOneBits
 
static constexpr uint16_t kMinusOneBits
 
- Protected Member Functions inherited from onnxruntime_float16::Float16Impl< Float16_t >
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 inherited from onnxruntime_float16::Float16Impl< Float16_t >
static constexpr uint16_t ToUint16Impl (float v) noexcept
 Converts from float to uint16_t float16 representation More...
 

Detailed Description

IEEE 754 half-precision floating point data type.

This struct is used for converting float to float16 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::Float16_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::Float16_t> fp16_values;
fp16_values.reserve(std::size(values));
std::transform(std::begin(values), std::end(values), std::back_inserter(fp16_values),
[](float value) { return Ort::Float16_t(value); });

Definition at line 164 of file onnxruntime_cxx_api.h.

Member Typedef Documentation

Constructor & Destructor Documentation

Ort::Float16_t::Float16_t ( )
default

Default constructor

Ort::Float16_t::Float16_t ( float  v)
inlineexplicitnoexcept

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

Parameters
vfloat value

Definition at line 192 of file onnxruntime_cxx_api.h.

Member Function Documentation

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

Explicit conversion to uint16_t representation of float16.

Parameters
vuint16_t bit representation of float16
Returns
new instance of Float16_t

Definition at line 186 of file onnxruntime_cxx_api.h.

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

User defined conversion operator. Converts Float16_t to float.

Definition at line 279 of file onnxruntime_cxx_api.h.

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

Converts float16 to float

Returns
float representation of float16 value

Definition at line 198 of file onnxruntime_cxx_api.h.


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