class InferenceEngine::Precision

Overview

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

#include <ie_precision.hpp>

class Precision
{
public:
    // enums

    enum ePrecision;

    // structs

    struct PrecisionInfo;

    // construction

    Precision();
    Precision(const Precision::ePrecision value);
    Precision(size_t bitsSize, const char \* name = nullptr);

    // methods

    template <class T>
    bool hasStorageType(const char \* typeName = nullptr) const;

    bool operator == (const Precision& p) const;
    bool operator == (const ePrecision p) const;
    bool operator != (const ePrecision p) const;
    Precision& operator = (const ePrecision p);
    operator bool () const;
    bool operator ! () const;
    operator Precision::ePrecision () const;
    constexpr uint8_t getPrecVal() const;
    const char \* name() const;
    size_t size() const;
    size_t bitsSize() const;
    bool is_float() const;
    bool isSigned() const;

    template <class T>
    static Precision fromType(const char \* typeName = nullptr);

    static Precision FromStr(const std::string& str);
};

Detailed Documentation

This class holds precision value and provides precision related operations.

Construction

Precision()

Default constructor.

Precision(const Precision::ePrecision value)

Constructor with specified precision.

Parameters:

value

A value of ePrecision to create an object from

Precision(size_t bitsSize, const char \* name = nullptr)

Custom precision constructor.

Parameters:

bitsSize

size of elements

name

optional: name string, used in serialisation

Methods

template <class T>
bool hasStorageType(const char \* typeName = nullptr) const

checks whether given storage class T can be used to store objects of current precision

Parameters:

typeName

A string name of precision

Returns:

true if typeName has underlaying storage type

bool operator == (const Precision& p) const

Equality operator with Precision object.

Parameters:

p

A value of Precision to compare with

Returns:

true if values represent the same precisions, false otherwise

bool operator == (const ePrecision p) const

Equality operator with ePrecision enum value.

Parameters:

p

A value of ePrecision to compare with

Returns:

true if values represent the same precisions, false otherwise

bool operator != (const ePrecision p) const

Inequality operator with ePrecision enum value.

Parameters:

p

A value of ePrecision to compare with

Returns:

true if values represent different precisions, false otherwise

Precision& operator = (const ePrecision p)

Assignment operator with ePrecision enum value.

Parameters:

p

A value of ePrecision enumeration

Returns:

A Precision instance

operator bool () const

Cast operator to a bool.

Returns:

true if precision is specified, false otherwise

bool operator ! () const

Logical negation operator.

Returns:

true if precision is NOT specified, false otherwise

operator Precision::ePrecision () const

Cast operator to a ePrecision.

Returns:

A casted value of Precision::ePrecision enumeration

constexpr uint8_t getPrecVal() const

Gets the precision value of type ePrecision.

Returns:

The preccision value.

const char \* name() const

Getter of precision name.

Returns:

A string representing precision name

size_t size() const

Returns size of single element of that precision in bytes.

Returns:

Number of bytes per element

size_t bitsSize() const

Returns size of single element of that precision in bits.

Returns:

Number of bits per element

bool is_float() const

Checks if it is a floating point value.

Returns:

True if precision is float point, false otherwise

bool isSigned() const

Checks if it is a signed value.

Returns:

True if precision is signed, false otherwise

template <class T>
static Precision fromType(const char \* typeName = nullptr)

Creates custom precision with specific underlined type.

Parameters:

typeName

A string name of precision

Returns:

Precision converted from string name

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

Creates Precision from string with precision name.

Parameters:

str

A string representing precision

Returns:

Precision created from string representation