AI Engine API User Guide (AIE-API) 2024.1
Loading...
Searching...
No Matches
Floating-point Conversion

Overview

Supported float to fixed conversions
bfloat16 float
Output bits Type Arch. Implementation Notes Implementation Notes
4b Scalar AIE
AIE-ML Runs on vector unit Runs on vector unit
Vector AIE
AIE-ML Emulated Uses aie::rounding_mode::symmetric_zero Emulated Uses aie::rounding_mode::symmetric_zero
8b Scalar AIE Native to 32b + cast
AIE-ML Runs on vector unit Runs on vector unit
Vector AIE Element-wise scalar
AIE-ML Emulated Uses aie::rounding_mode::symmetric_zero Emulated Uses aie::rounding_mode::symmetric_zero
16b Scalar AIE Native to 32b + cast
AIE-ML Runs on vector unit Runs on vector unit
Vector AIE Vectorized emulated impl
AIE-ML Native to 32b + extract lower 16b1 Uses aie::rounding_mode::floor Emulated Uses aie::rounding_mode::symmetric_zero
32b Scalar AIE Native
AIE-ML Runs on vector unit Runs on vector unit
Vector AIE Vectorized emulated impl
AIE-ML Native Uses aie::rounding_mode::floor Emulated Uses aie::rounding_mode::symmetric_zero
Note
1 - Unsigned conversions are emulated and use aie::rounding_mode::symmetric_zero.
Supported fixed to float conversions
Output type Type Arch. int4 int8 int16 int32
bfloat16 Scalar AIE
AIE-ML Runs on vector unit Runs on vector unit Runs on vector unit Runs on vector unit
Vector AIE
AIE-ML Emulated Emulated Emulated Emulated
float Scalar AIE Cast to int32 + native Cast to int32 + native Native
AIE-ML Runs on vector unit Runs on vector unit Runs on vector unit Runs on vector unit
Vector AIE Element-wise scalar Emulated Element-wise scalar
AIE-ML Emulated Emulated Emulated Emulated

Functions

template<typename TR = cint32>
requires (arch::is(arch::AIE, arch::AIE_ML) && Utils::is_one_of_v<TR, cint16, cint32>)
auto aie::to_fixed (cfloat a, int shift=0)
 Convert a floating point value into a fixed-point value.
 
template<typename TR = int32, unsigned Elems>
requires (arch::is(arch::AIE_ML))
auto aie::to_fixed (const vector< bfloat16, Elems > &v, int shift=0) -> vector< TR, Elems >
 Convert the elements in a bfloat16 vector into fixed-point values.
 
template<typename TR = cint32, unsigned Elems>
requires ((arch::is(arch::AIE) || (arch::is(arch::AIE_ML) && __AIE_API_COMPLEX_FP32_EMULATION__ == 1)) && Utils::is_one_of_v<TR, cint16, cint32>)
auto aie::to_fixed (const vector< cfloat, Elems > &v, int shift=0) -> vector< TR, Elems >
 Convert the elements in a floating point vector into fixed-point values.
 
template<typename TR = int32, unsigned Elems>
requires (Utils::is_one_of_v<TR, int16, int32>)
auto aie::to_fixed (const vector< float, Elems > &v, int shift=0) -> vector< TR, Elems >
 Convert the elements in a floating point vector into fixed-point values.
 
template<typename TR = int32>
requires (Utils::is_one_of_v<TR, int8, int16, int32>)
auto aie::to_fixed (float a, int shift=0)
 Convert a floating point value into a fixed-point value.
 
template<typename TR = float, typename T , unsigned Elems>
requires (Utils::is_one_of_v<T, int16, int32>)
auto aie::to_float (const vector< T, Elems > &v, int shift=0) -> vector< TR, Elems >
 Convert the elements in a real fixed-point vector into floating point values.
 
template<typename TR = float>
auto aie::to_float (int a, int shift=0)
 Convert a fixed-point value into a floating point value.
 
template<typename TR = cfloat, typename T >
requires (Utils::is_one_of_v<T, cint16, cint32>)
auto aie::to_float (T a, int shift=0)
 Convert a complex fixed-point value into a floating point value.
 

Function Documentation

◆ to_fixed() [1/5]

template<typename TR = cint32>
requires (arch::is(arch::AIE, arch::AIE_ML) && Utils::is_one_of_v<TR, cint16, cint32>)
auto aie::to_fixed ( cfloat  a,
int  shift = 0 
)

Convert a floating point value into a fixed-point value.

Parameters
aInput value.
shiftPosition of the point in the output value.
Template Parameters
TRType of the returned fixed-point value.

◆ to_fixed() [2/5]

template<typename TR = int32, unsigned Elems>
requires (arch::is(arch::AIE_ML))
auto aie::to_fixed ( const vector< bfloat16, Elems > &  v,
int  shift = 0 
) -> vector<TR, Elems>

Convert the elements in a bfloat16 vector into fixed-point values.

Note
This conversion performs floor rounding, regardless of the rounding_mode configured by the user.
Parameters
vInput vector.
shiftPosition of the point in the output values.
Template Parameters
TRType of the returned fixed-point values.

◆ to_fixed() [3/5]

template<typename TR = cint32, unsigned Elems>
requires ((arch::is(arch::AIE) || (arch::is(arch::AIE_ML) && __AIE_API_COMPLEX_FP32_EMULATION__ == 1)) && Utils::is_one_of_v<TR, cint16, cint32>)
auto aie::to_fixed ( const vector< cfloat, Elems > &  v,
int  shift = 0 
) -> vector<TR, Elems>

Convert the elements in a floating point vector into fixed-point values.

Parameters
vInput vector.
shiftPosition of the point in the output values.
Template Parameters
TRType of the returned fixed-point values.

◆ to_fixed() [4/5]

template<typename TR = int32, unsigned Elems>
requires (Utils::is_one_of_v<TR, int16, int32>)
auto aie::to_fixed ( const vector< float, Elems > &  v,
int  shift = 0 
) -> vector<TR, Elems>

Convert the elements in a floating point vector into fixed-point values.

Parameters
vInput vector.
shiftPosition of the point in the output values.
Template Parameters
TRType of the returned fixed-point values.

◆ to_fixed() [5/5]

template<typename TR = int32>
requires (Utils::is_one_of_v<TR, int8, int16, int32>)
auto aie::to_fixed ( float  a,
int  shift = 0 
)

Convert a floating point value into a fixed-point value.

Parameters
aInput value.
shiftPosition of the point in the output value.
Template Parameters
TRType of the returned fixed-point value.

◆ to_float() [1/3]

template<typename TR = float, typename T , unsigned Elems>
requires (Utils::is_one_of_v<T, int16, int32>)
auto aie::to_float ( const vector< T, Elems > &  v,
int  shift = 0 
) -> vector<TR, Elems>

Convert the elements in a real fixed-point vector into floating point values.

Parameters
vInput vector.
shiftPosition of the point in the input values.

◆ to_float() [2/3]

template<typename TR = float>
auto aie::to_float ( int  a,
int  shift = 0 
)

Convert a fixed-point value into a floating point value.

Parameters
aInput value.
shiftPosition of the point in the input value.

◆ to_float() [3/3]

template<typename TR = cfloat, typename T >
requires (Utils::is_one_of_v<T, cint16, cint32>)
auto aie::to_float ( a,
int  shift = 0 
)

Convert a complex fixed-point value into a floating point value.

Parameters
aInput value.
shiftPosition of the point in the input value.