AI Engine API User Guide (AIE) 2021.2
Basic Types

Overview

The two main types offered by the AIE API are vectors (aie::vector) and accumulators (aie::accum).

A vector represents a collection of elements of the same type which is transparently mapped to the corresponding vector registers supported on each architecture. Vectors are parametrized by the element type and the number of elements, and any combination that defines a 128b/256b/512b/1024b vector is supported.

Supported vector types and sizes
int8 uint8 int16 int32 float cint16 cint32 cfloat
16/32/64/128 16/32/64/128 8/16/32/64 4/8/16/32 4/8/16/32 4/8/16/32 2/4/8/16 2/4/8/16

An accumulator represents a collection of elements of the same class, typically obtained as a result of a multiplication operation, which is transparently mapped to the corresponding accumulator registers supported on each architecture. Accumulators commonly provide a large amount of bits, allowing users to perform long chains of operations whose intermediate results may exceed the range of regular vector types. Accumulators are parametrized by the element class, the required accumulation bits and the number of elements. Element class and accumulation bits are specified via type tags (seeAccumulator Element Tags). The accumulation bits define theminimumamount of bits and the AIE API maps them to the nearest native accumulator type that supports the requirement.

Supported accumulator types and sizes
acc32 acc40 acc48 acc56 acc64 acc72 acc80 accfloat cacc32 cacc40 cacc48 cacc56 cacc64 cacc72 cacc80 caccfloat
Sizes 8/16/32/64/128 8/16/32/64/128 8/16/32/64/128 8/16/32/64/128 4/8/16/32/64 4/8/16/32/64 4/8/16/32/64 4/8/16/32/64 4/8/16/32/64 4/8/16/32/64 4/8/16/32/64 4/8/16/32/64 2/4/8/16/32 2/4/8/16/32 2/4/8/16/32 2/4/8/16/32
Native accumulation 48b 48b 48b 80b 80b 80b 80b 32b 48b 48b 48b 80b 80b 80b 80b 32b
Portable Yes Yes Yes Yes Yes No No Yes Yes Yes Yes Yes Yes No No No

Some comparison operations return masks. A mask is a collection of values that can be 0 or 1.

Modules

Vector and Accumulator Initialization
Vector and Accumulator Conversions
Concepts for Basic Types
Accumulator Element Tags
Lazy Operations

Typedefs

template<AccumElemBaseTypeMinAccumTag, unsigned Elems>
using aie::accum=detail::accum< detail::accum_class_for_tag_v< MinAccumTag >, detail::accum_bits_for_tag_v< MinAccumTag >, Elems >
More...
template
using aie::mask=detail::mask< Elems >
More...
template<ElemBaseTypeT, unsigned Elems = native_vector_length_v>
using aie::vector=detail::vector< T, Elems >
More...
template<ElemBaseTypeT, unsigned N>
using aie::vector_elem_const_ref=detail::vector_elem_const_ref< T, N >
More...
template<ElemBaseTypeT, unsigned N>
using aie::vector_elem_ref=detail::vector_elem_ref< T, N >
More...

Typedef Documentation

accum

template< AccumElemBaseTypeMinAccumTag, unsigned Elems>
usingaie::accum= typedefdetail::accum, detail::accum_bits_for_tag_v, Elems>

Type for vector accumulators. The documentation of this class and its members can be found atdetail::accum.

Template Parameters
MinAccumTag Type tag that specifies the accumulator class and the required number of accumulation bits. Internally, this is rounded up to the smallest native accumulator size that meets the accuracy requirements. It must meetAccumElemBaseType.
Elems Number of elements in the accumulator.

mask

template
usingaie::mask= typedefdetail::mask

Type for vector element masks. The documentation of this class and its members can be found atdetail::mask.

This type is returned by logical operations and used as input in selection operations.

Template Parameters
Elems Number of elements represented in the mask.

vector

template< ElemBaseTypeT, unsigned Elems = native_vector_length_v>
usingaie::vector= typedefdetail::vector

Type for vector registers. The documentation of this class and its members can be found atdetail::vector.

Template Parameters
T Type of the elements contained in the vector. It must meetElemBaseType.
Elems Number of elements in the vector.

vector_elem_const_ref

Constant reference to vector element. This is similar toaie::vector_elem_ref, but the element cannot be modified.

Template Parameters
T Type of the elements contained in the referenced vector. It must meetElemBaseType.
Elems Number of elements in the referenced vector.

vector_elem_ref

template< ElemBaseTypeT, unsigned N>
usingaie::vector_elem_ref= typedefdetail::vector_elem_ref

Reference to vector element. This type is returned by element access functions and represents a proxy to the actual element, which allows for optimizations in the API such as accessing the element from its vector without extracting it. This is common in element / vector operations. Otherwise, the element value is extracted when assigned to a variable of type T.

Template Parameters
T Type of the elements contained in the referenced vector. It must meetElemBaseType.
Elems Number of elements in the referenced vector.