namespace InferenceEngine::PrecisionUtils¶
Overview¶
Namespace for precision utilities. More…
namespace PrecisionUtils {
// namespaces
namespace InferenceEngine::PrecisionUtils::details;
// global functions
ie_fp16 f32tof16(float x);
float f16tof32(ie_fp16 x);
void f16tof32Arrays(
float \* dst,
const ie_fp16 \* src,
size_t nelem,
float scale = 1.f,
float bias = 0.f
);
void f32tof16Arrays(
ie_fp16 \* dst,
const float \* src,
size_t nelem,
float scale = 1.f,
float bias = 0.f
);
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 saturate_cast(const InT& value);
template <class InT>
InT saturate_cast(const InT& value);
} // namespace PrecisionUtils
Detailed Documentation¶
Namespace for precision utilities.
Global Functions¶
ie_fp16 f32tof16(float x)
Converts a single-precision floating point value to a half-precision floating poit value.
Parameters:
x |
A single-precision floating point value |
Returns:
A half-precision floating point value
float f16tof32(ie_fp16 x)
Convers a half-precision floating point value to a single-precision floating point value.
Parameters:
x |
A half-precision floating point value |
Returns:
A single-precision floating point value
void 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:
dst |
A destination array of single-precision floating point values |
src |
A source array of half-precision floating point values |
nelem |
A number of elements in arrays |
scale |
An optional scale parameter |
bias |
An optional bias parameter |
void 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:
dst |
A destination array of half-precision floating point values |
src |
A sources array of single-precision floating point values |
nelem |
A number of elements in arrays |
scale |
An optional scale parameter |
bias |
An optional bias parameter |
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 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.
Parameters:
value |
Value to be converted |
Returns:
A saturated value
template <class InT>
InT 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.
Parameters:
value |
Value to be converted |
Returns:
A saturated value