AI Engine API User Guide (AIE) 2021.2
Vector and Accumulator Conversions

Overview

Vectors can be reinterpreted as vectors with a different element type, as long as they have the same total size.

v2 = v.cast_to<int32>(v);
v3 = aie::vector_cast<cint16>(v);
Definition: aie_declaration.hpp:68
int32_t int32
Definition: types.hpp:64

Vectors can be converted into accumulators. Their values can be shifted into a larger magnitude to implement fixed point precision schemes (this does not apply to floating point accumulators).

acc.from_vector(v, shift);
shift_bits< T, type_bits_v< T >, Elems > shift
Definition: shift.hpp:119
Definition: aie_declaration.hpp:71

Conversely, accumulators can be converted into vectors. Their values can be shifted down before rounding and saturation is applied (this does not apply to floating point accumulators).

v = acc.to_vector<int16>(shift);
int16_t int16
Definition: types.hpp:63

Functions

template<ElemBaseType DstT, Vector Vec>
auto aie::vector_cast (const Vec &v)
  More...
 

Function Documentation

◆ vector_cast()

template<ElemBaseType DstT, Vector Vec>
auto aie::vector_cast ( const Vec &  v)

Reinterpret a vector using a different element type. The returned vector has the same size in bits as the input vector.

Template Parameters
DstTElement type for the returned vector.
Parameters
vInput vector.