Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions
InferenceEngine::Precision Class Reference

This class holds precision value and provides precision related operations. More...

#include <ie_precision.hpp>

Public Types

enum  ePrecision : uint8_t {
  UNSPECIFIED = 255 , MIXED = 0 , FP32 = 10 , FP16 = 11 ,
  BF16 = 12 , FP64 = 13 , Q78 = 20 , I16 = 30 ,
  U4 = 39 , U8 = 40 , I4 = 49 , I8 = 50 ,
  U16 = 60 , I32 = 70 , U32 = 74 , I64 = 72 ,
  U64 = 73 , BIN = 71 , BOOL = 41 , CUSTOM = 80
}
 

Public Member Functions

 Precision ()=default
 Default constructor.
 
 Precision (const Precision::ePrecision value)
 Constructor with specified precision. More...
 
 Precision (size_t bitsSize, const char *name=nullptr)
 Custom precision constructor. More...
 
template<class T >
bool hasStorageType (const char *typeName=nullptr) const noexcept
 checks whether given storage class T can be used to store objects of current precision
 
bool operator== (const Precision &p) const noexcept
 Equality operator with Precision object. More...
 
bool operator== (const ePrecision p) const noexcept
 Equality operator with ePrecision enum value. More...
 
bool operator!= (const ePrecision p) const noexcept
 Inequality operator with ePrecision enum value. More...
 
Precisionoperator= (const ePrecision p) noexcept
 Assignment operator with ePrecision enum value. More...
 
 operator bool () const noexcept
 Cast operator to a bool. More...
 
bool operator! () const noexcept
 Logical negation operator. More...
 
 operator Precision::ePrecision () const noexcept
 Cast operator to a ePrecision. More...
 
constexpr uint8_t getPrecVal () const noexcept
 Gets the precision value of type ePrecision. More...
 
const char * name () const noexcept
 Getter of precision name. More...
 
size_t size () const
 Returns size of single element of that precision in bits. More...
 
bool is_float () const noexcept
 Checks if it is a floating point value. More...
 
bool isSigned () const noexcept
 Checks if it is a signed value. More...
 

Static Public Member Functions

template<class T >
static Precision fromType (const char *typeName=nullptr)
 Creates custom precision with specific underlined type.
 
static Precision FromStr (const std::string &str)
 Creates Precision from string with precision name. More...
 

Static Protected Member Functions

template<Precision::ePrecision precision>
static PrecisionInfo makePrecisionInfo (const char *name)
 Creates PrecisionInfo by precision with a specified name. More...
 
static bool areSameStrings (const char *l, const char *r) noexcept
 Compare two c-strings. More...
 
static PrecisionInfo getPrecisionInfo (ePrecision v)
 Creates PrecisionInfo based on ePrecision. More...
 

Detailed Description

This class holds precision value and provides precision related operations.

Member Enumeration Documentation

◆ ePrecision

Enum to specify of different

Enumerator
UNSPECIFIED 

Unspecified value. Used by default

MIXED 

Mixed value. Can be received from network. No applicable for tensors

FP32 

32bit floating point value

FP16 

16bit floating point value, 5 bit for exponent, 10 bit for mantisa

BF16 

16bit floating point value, 8 bit for exponent, 7 bit for mantisa

FP64 

64bit floating point value

Q78 

16bit specific signed fixed point precision

I16 

16bit signed integer value

U4 

4bit unsigned integer value

U8 

8bit unsigned integer value

I4 

4bit signed integer value

I8 

8bit signed integer value

U16 

16bit unsigned integer value

I32 

32bit signed integer value

U32 

32bit unsigned integer value

I64 

64bit signed integer value

U64 

64bit unsigned integer value

BIN 

1bit integer value

BOOL 

8bit bool type

CUSTOM 

custom precision has it's own name and size of elements

Constructor & Destructor Documentation

◆ Precision() [1/2]

InferenceEngine::Precision::Precision ( const Precision::ePrecision  value)
inline

Constructor with specified precision.

Parameters
valueA value of ePrecision to create an object from

◆ Precision() [2/2]

InferenceEngine::Precision::Precision ( size_t  bitsSize,
const char *  name = nullptr 
)
inlineexplicit

Custom precision constructor.

Parameters
bitsSizesize of elements
nameoptional: name string, used in serialisation

Member Function Documentation

◆ areSameStrings()

static bool InferenceEngine::Precision::areSameStrings ( const char *  l,
const char *  r 
)
inlinestaticprotectednoexcept

Compare two c-strings.

Parameters
lConst pointer to first string
rConst pointer to another string
Returns
True if strings are the same

◆ FromStr()

static Precision InferenceEngine::Precision::FromStr ( const std::string &  str)
inlinestatic

Creates Precision from string with precision name.

Parameters
strA string representing precision
Returns
Precision created from string representation

◆ getPrecisionInfo()

static PrecisionInfo InferenceEngine::Precision::getPrecisionInfo ( ePrecision  v)
inlinestaticprotected

Creates PrecisionInfo based on ePrecision.

Parameters
vA value of ePrecision emuneration
Returns
Precision info object

◆ getPrecVal()

constexpr uint8_t InferenceEngine::Precision::getPrecVal ( ) const
inlineconstexprnoexcept

Gets the precision value of type ePrecision.

Returns
The preccision value.

◆ is_float()

bool InferenceEngine::Precision::is_float ( ) const
inlinenoexcept

Checks if it is a floating point value.

Returns
True if precision is float point, false otherwise

◆ isSigned()

bool InferenceEngine::Precision::isSigned ( ) const
inlinenoexcept

Checks if it is a signed value.

Returns
True if precision is signed, false otherwise

◆ makePrecisionInfo()

template<Precision::ePrecision precision>
static PrecisionInfo InferenceEngine::Precision::makePrecisionInfo ( const char *  name)
staticprotected

Creates PrecisionInfo by precision with a specified name.

Template Parameters
precisionA precision to create PrecisionInfo for
Parameters
nameName of precision
Returns
A PrecisionInfo object

◆ name()

const char* InferenceEngine::Precision::name ( ) const
inlinenoexcept

Getter of precision name.

Returns
A string representing precision name

◆ operator bool()

InferenceEngine::Precision::operator bool ( ) const
inlineexplicitnoexcept

Cast operator to a bool.

Returns
true if precision is specified, false otherwise

◆ operator Precision::ePrecision()

InferenceEngine::Precision::operator Precision::ePrecision ( ) const
inlinenoexcept

Cast operator to a ePrecision.

Returns
A casted value of Precision::ePrecision enumeration

◆ operator!()

bool InferenceEngine::Precision::operator! ( ) const
inlinenoexcept

Logical negation operator.

Returns
true if precision is NOT specified, false otherwise

◆ operator!=()

bool InferenceEngine::Precision::operator!= ( const ePrecision  p) const
inlinenoexcept

Inequality operator with ePrecision enum value.

Parameters
pA value of ePrecision to compare with
Returns
true if values represent different precisions, false otherwise

◆ operator=()

Precision& InferenceEngine::Precision::operator= ( const ePrecision  p)
inlinenoexcept

Assignment operator with ePrecision enum value.

Parameters
pA value of ePrecision enumeration
Returns
A Precision instance

◆ operator==() [1/2]

bool InferenceEngine::Precision::operator== ( const ePrecision  p) const
inlinenoexcept

Equality operator with ePrecision enum value.

Parameters
pA value of ePrecision to compare with
Returns
true if values represent the same precisions, false otherwise

◆ operator==() [2/2]

bool InferenceEngine::Precision::operator== ( const Precision p) const
inlinenoexcept

Equality operator with Precision object.

Parameters
pA value of Precision to compare with
Returns
true if values represent the same precisions, false otherwise

◆ size()

size_t InferenceEngine::Precision::size ( ) const
inline

Returns size of single element of that precision in bits.

Returns
Number of bytes per element

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