Typedefs | Functions
FP16 to FP32 precision utilities

Set of functions to convert from FP32 to FP16 and vice versa. More...

Typedefs

using InferenceEngine::ie_fp16 = short
 A type difinition for FP16 data type. Defined as a singed short.
 

Functions

ie_fp16 InferenceEngine::PrecisionUtils::f32tof16 (float x)
 Converts a single-precision floating point value to a half-precision floating poit value. More...
 
float InferenceEngine::PrecisionUtils::f16tof32 (ie_fp16 x)
 Convers a half-precision floating point value to a single-precision floating point value. More...
 
void InferenceEngine::PrecisionUtils::f16tof32Arrays (float *dst, const ie_fp16 *src, size_t nelem, float scale=1.f, float bias=0.f)
 Converts a half-precision floating point array to single-precision floating point array and applies scale and bias is needed. More...
 
void InferenceEngine::PrecisionUtils::f32tof16Arrays (ie_fp16 *dst, const float *src, size_t nelem, float scale=1.f, float bias=0.f)
 Converts a single-precision floating point array to a half-precision floating point array and applies scale and bias if needed. More...
 
template<class OutT , class InT , typename std::enable_if< std::is_integral< OutT >::value &&std::is_integral< InT >::value &&std::is_signed< InT >::value &&!std::is_same< OutT, InT >::value >::type * = nullptr>
OutT InferenceEngine::PrecisionUtils::saturate_cast (const InT &value)
 Converts one integral type to another saturating the result if the source value doesn't fit into destination type range. More...
 
template<class InT >
InT InferenceEngine::PrecisionUtils::saturate_cast (const InT &value)
 Converts one integral type to another saturating the result if the source value doesn't fit into destination type range. More...
 

Detailed Description

Set of functions to convert from FP32 to FP16 and vice versa.

Function Documentation

◆ f16tof32()

float InferenceEngine::PrecisionUtils::f16tof32 ( ie_fp16  x)

Convers a half-precision floating point value to a single-precision floating point value.

Parameters
[in]xA half-precision floating point value
Returns
A single-precision floating point value

◆ f16tof32Arrays()

void InferenceEngine::PrecisionUtils::f16tof32Arrays ( float *  dst,
const ie_fp16 src,
size_t  nelem,
float  scale = 1.f,
float  bias = 0.f 
)

Converts a half-precision floating point array to single-precision floating point array and applies scale and bias is needed.

Parameters
dstA destination array of single-precision floating point values
[in]srcA source array of half-precision floating point values
[in]nelemA number of elements in arrays
[in]scaleAn optional scale parameter
[in]biasAn optional bias parameter

◆ f32tof16()

ie_fp16 InferenceEngine::PrecisionUtils::f32tof16 ( float  x)

Converts a single-precision floating point value to a half-precision floating poit value.

Parameters
[in]xA single-precision floating point value
Returns
A half-precision floating point value

◆ f32tof16Arrays()

void InferenceEngine::PrecisionUtils::f32tof16Arrays ( ie_fp16 dst,
const float *  src,
size_t  nelem,
float  scale = 1.f,
float  bias = 0.f 
)

Converts a single-precision floating point array to a half-precision floating point array and applies scale and bias if needed.

Parameters
dstA destination array of half-precision floating point values
[in]srcA sources array of single-precision floating point values
[in]nelemA number of elements in arrays
[in]scaleAn optional scale parameter
[in]biasAn optional bias parameter

◆ saturate_cast() [1/2]

template<class OutT , class InT , typename std::enable_if< std::is_integral< OutT >::value &&std::is_integral< InT >::value &&std::is_signed< InT >::value &&!std::is_same< OutT, InT >::value >::type * = nullptr>
OutT InferenceEngine::PrecisionUtils::saturate_cast ( const InT &  value)
inline

Converts one integral type to another saturating the result if the source value doesn't fit into destination type range.

Parameters
valueValue to be converted
Returns
A saturated value

◆ saturate_cast() [2/2]

template<class InT >
InT InferenceEngine::PrecisionUtils::saturate_cast ( const InT &  value)
inline

Converts one integral type to another saturating the result if the source value doesn't fit into destination type range.

Parameters
valueValue to be converted
Returns
A saturated value