TensorRT  7.2.1.6
NVIDIA TensorRT
Looking for a C++ dev who knows TensorRT?
I'm looking for work. Hire me!
half_float::half Class Reference

Half-precision floating point type. More...

Collaboration diagram for half_float::half:

Public Member Functions

 half ()
 Default constructor. More...
 
 half (detail::expr rhs)
 Copy constructor. More...
 
 half (float rhs)
 Conversion constructor. More...
 
 operator float () const
 Conversion to single-precision. More...
 
halfoperator= (detail::expr rhs)
 Assignment operator. More...
 
template<typename T >
detail::enable< half &, T >::type operator+= (T rhs)
 Arithmetic assignment. More...
 
template<typename T >
detail::enable< half &, T >::type operator-= (T rhs)
 Arithmetic assignment. More...
 
template<typename T >
detail::enable< half &, T >::type operator*= (T rhs)
 Arithmetic assignment. More...
 
template<typename T >
detail::enable< half &, T >::type operator/= (T rhs)
 Arithmetic assignment. More...
 
halfoperator= (float rhs)
 Assignment operator. More...
 
halfoperator+= (float rhs)
 Arithmetic assignment. More...
 
halfoperator-= (float rhs)
 Arithmetic assignment. More...
 
halfoperator*= (float rhs)
 Arithmetic assignment. More...
 
halfoperator/= (float rhs)
 Arithmetic assignment. More...
 
halfoperator++ ()
 Prefix increment. More...
 
halfoperator-- ()
 Prefix decrement. More...
 
half operator++ (int)
 Postfix increment. More...
 
half operator-- (int)
 Postfix decrement. More...
 
 half ()
 Default constructor. More...
 
 half (detail::expr rhs)
 Copy constructor. More...
 
 half (float rhs)
 Conversion constructor. More...
 
 operator float () const
 Conversion to single-precision. More...
 
halfoperator= (detail::expr rhs)
 Assignment operator. More...
 
template<typename T >
detail::enable< half &, T >::type operator+= (T rhs)
 Arithmetic assignment. More...
 
template<typename T >
detail::enable< half &, T >::type operator-= (T rhs)
 Arithmetic assignment. More...
 
template<typename T >
detail::enable< half &, T >::type operator*= (T rhs)
 Arithmetic assignment. More...
 
template<typename T >
detail::enable< half &, T >::type operator/= (T rhs)
 Arithmetic assignment. More...
 
halfoperator= (float rhs)
 Assignment operator. More...
 
halfoperator+= (float rhs)
 Arithmetic assignment. More...
 
halfoperator-= (float rhs)
 Arithmetic assignment. More...
 
halfoperator*= (float rhs)
 Arithmetic assignment. More...
 
halfoperator/= (float rhs)
 Arithmetic assignment. More...
 
halfoperator++ ()
 Prefix increment. More...
 
halfoperator-- ()
 Prefix decrement. More...
 
half operator++ (int)
 Postfix increment. More...
 
half operator-- (int)
 Postfix decrement. More...
 

Private Member Functions

 half (detail::binary_t, detail::uint16 bits)
 Constructor. More...
 
 half (detail::binary_t, detail::uint16 bits)
 Constructor. More...
 

Private Attributes

detail::uint16 data_
 Internal binary representation. More...
 

Static Private Attributes

static const std::float_round_style round_style = (std::float_round_style)( 1 )
 Rounding mode to use. More...
 

Friends

struct detail::functions
 
struct detail::unary_specialized< half >
 
struct detail::binary_specialized< half, half >
 
template<typename , typename , std::float_round_style >
struct detail::half_caster
 
class std::numeric_limits< half >
 
template<typename , typename , std::float_round_style >
struct detail::half_caster
 

Detailed Description

Half-precision floating point type.

This class implements an IEEE-conformant half-precision floating point type with the usual arithmetic operators and conversions. It is implicitly convertible to single-precision floating point, which makes artihmetic expressions and functions with mixed-type operands to be of the most precise operand type. Additionally all arithmetic operations (and many mathematical functions) are carried out in single-precision internally. All conversions from single- to half-precision are done using the library's default rounding mode, but temporary results inside chained arithmetic expressions are kept in single-precision as long as possible (while of course still maintaining a strong half-precision type).

According to the C++98/03 definition, the half type is not a POD type. But according to C++11's less strict and extended definitions it is both a standard layout type and a trivially copyable type (even if not a POD type), which means it can be standard-conformantly copied using raw binary copies. But in this context some more words about the actual size of the type. Although the half is representing an IEEE 16-bit type, it does not neccessarily have to be of exactly 16-bits size. But on any reasonable implementation the actual binary representation of this type will most probably not ivolve any additional "magic" or padding beyond the simple binary representation of the underlying 16-bit IEEE number, even if not strictly guaranteed by the standard. But even then it only has an actual size of 16 bits if your C++ implementation supports an unsigned integer type of exactly 16 bits width. But this should be the case on nearly any reasonable platform.

So if your C++ implementation is not totally exotic or imposes special alignment requirements, it is a reasonable assumption that the data of a half is just comprised of the 2 bytes of the underlying IEEE representation.

Constructor & Destructor Documentation

◆ half() [1/8]

half_float::half::half ( )
inline

Default constructor.

This initializes the half to 0. Although this does not match the builtin types' default-initialization semantics and may be less efficient than no initialization, it is needed to provide proper value-initialization semantics.

◆ half() [2/8]

half_float::half::half ( detail::expr  rhs)
inline

Copy constructor.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to copy from

◆ half() [3/8]

half_float::half::half ( float  rhs)
inlineexplicit

Conversion constructor.

Parameters
rhsfloat to convert

◆ half() [4/8]

half_float::half::half ( detail::binary_t  ,
detail::uint16  bits 
)
inlineprivate

Constructor.

Parameters
bitsbinary representation to set half to

◆ half() [5/8]

half_float::half::half ( )
inline

Default constructor.

This initializes the half to 0. Although this does not match the builtin types' default-initialization semantics and may be less efficient than no initialization, it is needed to provide proper value-initialization semantics.

◆ half() [6/8]

half_float::half::half ( detail::expr  rhs)
inline

Copy constructor.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to copy from

◆ half() [7/8]

half_float::half::half ( float  rhs)
inlineexplicit

Conversion constructor.

Parameters
rhsfloat to convert

◆ half() [8/8]

half_float::half::half ( detail::binary_t  ,
detail::uint16  bits 
)
inlineprivate

Constructor.

Parameters
bitsbinary representation to set half to

Member Function Documentation

◆ operator float() [1/2]

half_float::half::operator float ( ) const
inline

Conversion to single-precision.

Returns
single precision value representing expression value

◆ operator=() [1/4]

half& half_float::half::operator= ( detail::expr  rhs)
inline

Assignment operator.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to copy from
Returns
reference to this half

◆ operator+=() [1/4]

template<typename T >
detail::enable<half&,T>::type half_float::half::operator+= ( rhs)
inline

Arithmetic assignment.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to add
Returns
reference to this half

◆ operator-=() [1/4]

template<typename T >
detail::enable<half&,T>::type half_float::half::operator-= ( rhs)
inline

Arithmetic assignment.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to subtract
Returns
reference to this half

◆ operator*=() [1/4]

template<typename T >
detail::enable<half&,T>::type half_float::half::operator*= ( rhs)
inline

Arithmetic assignment.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to multiply with
Returns
reference to this half

◆ operator/=() [1/4]

template<typename T >
detail::enable<half&,T>::type half_float::half::operator/= ( rhs)
inline

Arithmetic assignment.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to divide by
Returns
reference to this half

◆ operator=() [2/4]

half& half_float::half::operator= ( float  rhs)
inline

Assignment operator.

Parameters
rhssingle-precision value to copy from
Returns
reference to this half

◆ operator+=() [2/4]

half& half_float::half::operator+= ( float  rhs)
inline

Arithmetic assignment.

Parameters
rhssingle-precision value to add
Returns
reference to this half

◆ operator-=() [2/4]

half& half_float::half::operator-= ( float  rhs)
inline

Arithmetic assignment.

Parameters
rhssingle-precision value to subtract
Returns
reference to this half

◆ operator*=() [2/4]

half& half_float::half::operator*= ( float  rhs)
inline

Arithmetic assignment.

Parameters
rhssingle-precision value to multiply with
Returns
reference to this half

◆ operator/=() [2/4]

half& half_float::half::operator/= ( float  rhs)
inline

Arithmetic assignment.

Parameters
rhssingle-precision value to divide by
Returns
reference to this half

◆ operator++() [1/4]

half& half_float::half::operator++ ( )
inline

Prefix increment.

Returns
incremented half value

◆ operator--() [1/4]

half& half_float::half::operator-- ( )
inline

Prefix decrement.

Returns
decremented half value

◆ operator++() [2/4]

half half_float::half::operator++ ( int  )
inline

Postfix increment.

Returns
non-incremented half value

◆ operator--() [2/4]

half half_float::half::operator-- ( int  )
inline

Postfix decrement.

Returns
non-decremented half value

◆ operator float() [2/2]

half_float::half::operator float ( ) const
inline

Conversion to single-precision.

Returns
single precision value representing expression value

◆ operator=() [3/4]

half& half_float::half::operator= ( detail::expr  rhs)
inline

Assignment operator.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to copy from
Returns
reference to this half

◆ operator+=() [3/4]

template<typename T >
detail::enable<half&, T>::type half_float::half::operator+= ( rhs)
inline

Arithmetic assignment.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to add
Returns
reference to this half

◆ operator-=() [3/4]

template<typename T >
detail::enable<half&, T>::type half_float::half::operator-= ( rhs)
inline

Arithmetic assignment.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to subtract
Returns
reference to this half

◆ operator*=() [3/4]

template<typename T >
detail::enable<half&, T>::type half_float::half::operator*= ( rhs)
inline

Arithmetic assignment.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to multiply with
Returns
reference to this half

◆ operator/=() [3/4]

template<typename T >
detail::enable<half&, T>::type half_float::half::operator/= ( rhs)
inline

Arithmetic assignment.

Template Parameters
Ttype of concrete half expression
Parameters
rhshalf expression to divide by
Returns
reference to this half

◆ operator=() [4/4]

half& half_float::half::operator= ( float  rhs)
inline

Assignment operator.

Parameters
rhssingle-precision value to copy from
Returns
reference to this half

◆ operator+=() [4/4]

half& half_float::half::operator+= ( float  rhs)
inline

Arithmetic assignment.

Parameters
rhssingle-precision value to add
Returns
reference to this half

◆ operator-=() [4/4]

half& half_float::half::operator-= ( float  rhs)
inline

Arithmetic assignment.

Parameters
rhssingle-precision value to subtract
Returns
reference to this half

◆ operator*=() [4/4]

half& half_float::half::operator*= ( float  rhs)
inline

Arithmetic assignment.

Parameters
rhssingle-precision value to multiply with
Returns
reference to this half

◆ operator/=() [4/4]

half& half_float::half::operator/= ( float  rhs)
inline

Arithmetic assignment.

Parameters
rhssingle-precision value to divide by
Returns
reference to this half

◆ operator++() [3/4]

half& half_float::half::operator++ ( )
inline

Prefix increment.

Returns
incremented half value

◆ operator--() [3/4]

half& half_float::half::operator-- ( )
inline

Prefix decrement.

Returns
decremented half value

◆ operator++() [4/4]

half half_float::half::operator++ ( int  )
inline

Postfix increment.

Returns
non-incremented half value

◆ operator--() [4/4]

half half_float::half::operator-- ( int  )
inline

Postfix decrement.

Returns
non-decremented half value

Friends And Related Function Documentation

◆ detail::functions

◆ detail::unary_specialized< half >

friend struct detail::unary_specialized< half >
friend

◆ detail::binary_specialized< half, half >

friend struct detail::binary_specialized< half, half >
friend

◆ detail::half_caster [1/2]

template<typename , typename , std::float_round_style >
friend struct detail::half_caster
friend

◆ std::numeric_limits< half >

friend class std::numeric_limits< half >
friend

◆ detail::half_caster [2/2]

template<typename , typename , std::float_round_style >
struct detail::half_caster
friend

Member Data Documentation

◆ round_style

static const std::float_round_style half_float::half::round_style = (std::float_round_style)( 1 )
staticprivate

Rounding mode to use.

◆ data_

detail::uint16 half_float::half::data_
private

Internal binary representation.


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