| AI Engine API User Guide (AIE-API) 2026.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 XDNA1 | Runs on vector unit |  | Runs on vector unit |
XDNA2 | Runs on vector unit |  | Runs on vector unit |
AIE-MLv2 | Runs on vector unit |  | Runs on vector unit |
Vector | AIE |  |  |  |
AIE-ML XDNA1 | Emulated | Uses aie::rounding_mode::conv_even | Emulated | Uses aie::rounding_mode::conv_even
XDNA2 | Emulated | Uses aie::rounding_mode::conv_even | Emulated | Uses aie::rounding_mode::conv_even
AIE-MLv2 | Emulated | Uses aie::rounding_mode::conv_even | Emulated | Uses aie::rounding_mode::conv_even
8b | Scalar | AIE |  |  | Native to 32b + cast |
AIE-ML XDNA1 | Runs on vector unit |  | Runs on vector unit |
XDNA2 | Runs on vector unit |  | Runs on vector unit |
AIE-MLv2 | Runs on vector unit |  | Runs on vector unit |
Vector | AIE |  |  | Element-wise scalar |
AIE-ML XDNA1 | Emulated | Uses aie::rounding_mode::conv_even | Emulated | Uses aie::rounding_mode::conv_even
XDNA2 | Emulated | Uses aie::rounding_mode::conv_even | Emulated | Uses aie::rounding_mode::conv_even
AIE-MLv2 | Emulated | Uses aie::rounding_mode::conv_even | Emulated | Uses aie::rounding_mode::conv_even
16b | Scalar | AIE |  |  | Native to 32b + cast |
AIE-ML XDNA1 | Runs on vector unit |  | Runs on vector unit |
XDNA2 | Runs on vector unit |  | Native | Uses aie::rounding_mode::conv_even
AIE-MLv2 | Runs on vector unit |  | Native | Uses aie::rounding_mode::conv_even
Vector | AIE |  |  | Vectorized emulated impl |
AIE-ML XDNA1 | Native to 32b + extract lower 16b1 | Uses aie::rounding_mode::conv_even | Emulated | Uses aie::rounding_mode::conv_even
XDNA2 | Native to 32b + extract lower 16b1 | Uses aie::rounding_mode::conv_even | Emulated | Uses aie::rounding_mode::conv_even
AIE-MLv2 | Native to 32b + extract lower 16b1 | Uses aie::rounding_mode::conv_even | Emulated | Uses aie::rounding_mode::conv_even
32b | Scalar | AIE |  |  | Native |
AIE-ML XDNA1 | Runs on vector unit |  | Runs on vector unit |
XDNA2 | Runs on vector unit |  | Native | Uses aie::rounding_mode::conv_even
AIE-MLv2 | Runs on vector unit |  | Native | Uses aie::rounding_mode::conv_even
Vector | AIE |  |  | Vectorized emulated impl |
AIE-ML XDNA1 | Native | Uses aie::rounding_mode::conv_even | Emulated | Uses aie::rounding_mode::conv_even
XDNA2 | Native | Uses aie::rounding_mode::conv_even | Emulated | Uses aie::rounding_mode::conv_even
AIE-MLv2 | Native | Uses aie::rounding_mode::conv_even | Emulated | Uses aie::rounding_mode::conv_even

Note
  1
    Unsigned conversions are emulated and use aie::rounding_mode::conv_even.

Supported fixed to float conversions
Output type | Type | Arch. | int4 | int8 | int16 | int32
--- | --- | --- | --- | --- | --- | ---
bfloat16 | Scalar | AIE |  |  |  |
AIE-ML XDNA1 | Runs on vector unit | Runs on vector unit | Runs on vector unit | Runs on vector unit
XDNA2 | Runs on vector unit | Runs on vector unit | Runs on vector unit | Runs on vector unit
AIE-MLv2 | Runs on vector unit | Runs on vector unit | Runs on vector unit | Runs on vector unit
Vector | AIE |  |  |  |
AIE-ML XDNA1 | Emulated | Emulated | Emulated | Emulated
XDNA2 | Emulated | Emulated | Emulated | Emulated
AIE-MLv2 | Emulated | Emulated | Emulated | Emulated
float | Scalar | AIE |  | Cast to int32 + native | Cast to int32 + native | Native
AIE-ML XDNA1 | Runs on vector unit | Runs on vector unit | Runs on vector unit | Runs on vector unit
XDNA2 | Cast to int32 + native | Cast to int32 + native | Cast to int32 + native | Native
AIE-MLv2 | Cast to int32 + native | Cast to int32 + native | Cast to int32 + native | Native
Vector | AIE |  | Element-wise scalar | Emulated | Element-wise scalar
AIE-ML XDNA1 | Emulated | Emulated | Emulated | Emulated
XDNA2 | Emulated | Emulated | Emulated | Emulated
AIE-MLv2 | 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 complex floating-point value into a complex fixed-point value, with each component rounded to the nearest integer.
template<typename TR = int32, unsigned Elems> requires (arch::is(arch::Gen2) && Utils::is_one_of_v<TR, int4, uint4, int8, uint8, int16, uint16, int32, uint32>)
auto | aie::to_fixed (const accum< accfloat, Elems > &v, int shift=0) -> vector< TR, Elems >
| Convert the elements in a floating point accumulator into a vector of 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 ((arch::is(arch::Gen2) && Utils::is_one_of_v<TR, int4, uint4, int8, uint8, int16, uint16, int32, uint32>) || (arch::is(arch::Gen1) && 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, typename T, unsigned Elems> requires (arch::is(arch::Gen2) && std::is_same_v<T, bfloat16>)
auto | aie::to_fixed (const vector< T, Elems > &v, int shift=0) -> vector< TR, Elems >
| Convert the elements in a bfloat16 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, rounded to the nearest integer.
template<typename TR = int32, typename T, unsigned Elems> requires (arch::is(arch::Gen2) && Utils::is_one_of_v<TR, int16, int32> && (arch::is(arch::Gen2) && std::is_same_v<T, bfloat16>))
auto | aie::to_fixed_floor (const vector< T, Elems > &v, int shift=0) -> vector< TR, Elems >
| Convert the elements in a bfloat16 vector into floored fixed-point values.
template<typename TR = int32, unsigned Elems> requires (arch::is(arch::Gen2) && Utils::is_one_of_v<TR, int4, int8, int16, int32>)
auto | aie::to_fixed_sign (const accum< accfloat, Elems > &v, bool v_sign, int shift=0) -> vector< TR, Elems >
| Convert the elements in a floating point accumulator into a vector of fixed-point values.
template<typename TR = int32, typename T, unsigned Elems> requires (!detail::is_floating_point_v<TR> && detail::is_signed_v<TR> && detail::is_floating_point_v<T> && detail::type_bits_v<TR> <= detail::type_bits_v<T> && arch::is(arch::Gen2))
auto | aie::to_fixed_sign (const vector< T, Elems > &v, bool v_sign, int shift=0) -> vector< TR, Elems >
| Convert the elements in a floating point vector into fixed-point values.
template<typename TR = float, Accum Acc> requires (std::is_same_v<TR, float> && arch::is(arch::Gen2))
auto | aie::to_float (const Acc &acc, int shift=0) -> vector< TR, Acc::size()>
| Convert the elements in a real fixed-point accumulator into floating point values.
template<typename TR = float, VectorOrOp Vec> requires ((arch::is(arch::Gen2) && Utils::is_one_of_v<typename Vec::value_type, int4, uint4, int8, uint8, int16, uint16, int32, uint32>) || (arch::is(arch::Gen1) && Utils::is_one_of_v<typename Vec::value_type, int16, int32>))
auto | aie::to_float (const Vec &v, int shift=0) -> vector< TR, Vec::size()>
| Convert the elements in a real fixed-point vector into floating point values.
template<typename TR = cfloat, typename T, unsigned Elems> requires (Utils::is_one_of_v<T, cint16, cint32>)
auto | aie::to_float (const vector< T, Elems > &v, int shift=0) -> vector< TR, Elems >
| Convert the elements in a complex 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/6]

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 complex floating-point value into a complex fixed-point value, with each component rounded to the nearest integer.

Parameters

  a | Input value.
  shift | Position of the point in the output value.

Template Parameters

  TR | Type of the returned fixed-point value.

Note
  Global settings, such as rounding and saturation modes, do not affect this API. The conversion relies on a hardware `float2fix()` implementation that applies a fixed round-to-nearest behavior and does not observe software-configured rounding modes (e.g. aie::set_rounding(aie::rounding_mode::floor) has no effect here).

## ◆ to_fixed() [2/6]

template<typename TR = int32, unsigned Elems>
requires (arch::is(arch::Gen2) && Utils::is_one_of_v<TR, int4, uint4, int8, uint8, int16, uint16, int32, uint32>)

auto aie::to_fixed | ( | const accum< accfloat, Elems > & | v,
|  | int | shift = 0 )->vector< TR, Elems >

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

Parameters

  v | Input accumulator.
  shift | Position of the point in the output values.

Template Parameters

  TR | Type of the returned fixed-point values.

## ◆ to_fixed() [3/6]

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

  v | Input vector.
  shift | Position of the point in the output values.

Template Parameters

  TR | Type of the returned fixed-point values.

## ◆ to_fixed() [4/6]

template<typename TR = int32, unsigned Elems>
requires ((arch::is(arch::Gen2) && Utils::is_one_of_v<TR, int4, uint4, int8, uint8, int16, uint16, int32, uint32>) || (arch::is(arch::Gen1) && 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

  v | Input vector.
  shift | Position of the point in the output values.

Template Parameters

  TR | Type of the returned fixed-point values.

## ◆ to_fixed() [5/6]

template<typename TR = int32, typename T, unsigned Elems>
requires (arch::is(arch::Gen2) && std::is_same_v<T, bfloat16>)

auto aie::to_fixed | ( | const vector< T, Elems > & | v,
|  | int | shift = 0 )->vector< TR, Elems >

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

Parameters

  v | Input vector.
  shift | Position of the point in the output values.

Template Parameters

  TR | Type of the returned fixed-point values.

## ◆ to_fixed() [6/6]

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, rounded to the nearest integer.

Parameters

  a | Input value.
  shift | Position of the point in the output value.

Template Parameters

  TR | Type of the returned fixed-point value.

Note
  Global settings, such as rounding and saturation modes, do not affect this API. The conversion relies on a hardware `float2fix()` implementation that applies a fixed round-to-nearest behavior (e.g. aie::set_rounding(aie::rounding_mode::floor) has no effect here).

## ◆ to_fixed_floor()

template<typename TR = int32, typename T, unsigned Elems>
requires (arch::is(arch::Gen2) && Utils::is_one_of_v<TR, int16, int32> && (arch::is(arch::Gen2) && std::is_same_v<T, bfloat16>))

auto aie::to_fixed_floor | ( | const vector< T, Elems > & | v,
|  | int | shift = 0 )->vector< TR, Elems >

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

Parameters

  v | Input vector.
  shift | Position of the point in the output values.

Template Parameters

  TR | Type of the returned fixed-point values.

## ◆ to_fixed_sign() [1/2]

template<typename TR = int32, unsigned Elems>
requires (arch::is(arch::Gen2) && Utils::is_one_of_v<TR, int4, int8, int16, int32>)

auto aie::to_fixed_sign | ( | const accum< accfloat, Elems > & | v,
|  | bool | v_sign,
|  | int | shift = 0 )->vector< TR, Elems >

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

Parameters

  v | Input accumulator.
  v_sign | Dynamic sign of the point in the output values.
  shift | Position of the point in the output values.

Template Parameters

  TR | Type of the returned fixed-point values.

## ◆ to_fixed_sign() [2/2]

template<typename TR = int32, typename T, unsigned Elems>
requires (!detail::is_floating_point_v<TR> && detail::is_signed_v<TR> && detail::is_floating_point_v<T> && detail::type_bits_v<TR> <= detail::type_bits_v<T> && arch::is(arch::Gen2))

auto aie::to_fixed_sign | ( | const vector< T, Elems > & | v,
|  | bool | v_sign,
|  | int | shift = 0 )->vector< TR, Elems >

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

Parameters

  v | Input vector.
  shift | Position of the point in the output values.

Template Parameters

  TR | Return element type of the result vector. Must be a signed integer type.

## ◆ to_float() [1/5]

template<typename TR = float, Accum Acc>
requires (std::is_same_v<TR, float> && arch::is(arch::Gen2))

auto aie::to_float | ( | const Acc & | acc,
|  | int | shift = 0 )->vector< TR, Acc::size()>

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

Parameters

  acc | Input accumulator.
  shift | Position of the point in the input values.

## ◆ to_float() [2/5]

template<typename TR = float, VectorOrOp Vec>
requires ((arch::is(arch::Gen2) && Utils::is_one_of_v<typename Vec::value_type, int4, uint4, int8, uint8, int16, uint16, int32, uint32>) || (arch::is(arch::Gen1) && Utils::is_one_of_v<typename Vec::value_type, int16, int32>))

auto aie::to_float | ( | const Vec & | v,
|  | int | shift = 0 )->vector< TR, Vec::size()>

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

Parameters

  v | Input vector.
  shift | Position of the point in the input values.

## ◆ to_float() [3/5]

template<typename TR = cfloat, typename T, unsigned Elems>
requires (Utils::is_one_of_v<T, cint16, cint32>)

auto aie::to_float | ( | const vector< T, Elems > & | v,
|  | int | shift = 0 )->vector< TR, Elems >

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

Parameters

  v | Input vector.
  shift | Position of the point in the input values.

## ◆ to_float() [4/5]

template<typename TR = float>

auto aie::to_float | ( | int | a,
|  | int | shift = 0 )

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

Parameters

  a | Input value.
  shift | Position of the point in the input value.

## ◆ to_float() [5/5]

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.

Parameters

  a | Input value.
  shift | Position of the point in the input value.