AI Engine API User Guide (AIE) 2022.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
int8uint8int16int32floatcint16cint32cfloat
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 (see Accumulator Element Tags). The accumulation bits define the minimum amount of bits and the AIE API maps them to the nearest native accumulator type that supports the requirement.

Supported accumulator types and sizes
acc32acc40acc48acc56acc64acc72acc80accfloat cacc32cacc40cacc48cacc56cacc64cacc72cacc80caccfloat
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<AccumElemBaseType MinAccumTag, unsigned Elems>
using aie::accum = detail::accum< detail::accum_class_for_tag_v< MinAccumTag >, detail::accum_bits_for_tag_v< MinAccumTag >, Elems >
  More...
 
template<unsigned Elems>
using aie::mask = detail::mask< Elems >
  More...
 
template<ElemBaseType T, unsigned Elems = native_vector_length_v<T>, aie_dm_resource Resource = aie_dm_resource::none>
using aie::unaligned_vector_ref = detail::unaligned_vector_ref< T, Elems, Resource >
  More...
 
template<ElemBaseType T, unsigned Elems = native_vector_length_v<T>>
using aie::vector = detail::vector< T, Elems >
  More...
 
template<ElemBaseType T, unsigned N>
using aie::vector_elem_const_ref = detail::vector_elem_const_ref< T, N >
  More...
 
template<ElemBaseType T, unsigned N>
using aie::vector_elem_ref = detail::vector_elem_ref< T, N >
  More...
 
template<ElemBaseType T, unsigned Elems = native_vector_length_v<T>, aie_dm_resource Resource = aie_dm_resource::none>
using aie::vector_ref = detail::vector_ref< T, Elems, Resource >
  More...
 

Typedef Documentation

◆ accum

template<AccumElemBaseType MinAccumTag, unsigned Elems>
using aie::accum = typedef detail::accum<detail::accum_class_for_tag_v<MinAccumTag>, detail::accum_bits_for_tag_v<MinAccumTag>, Elems>

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

Template Parameters
MinAccumTagType 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 meet AccumElemBaseType.
ElemsNumber of elements in the accumulator.

◆ mask

template<unsigned Elems>
using aie::mask = typedef detail::mask<Elems>

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

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

Template Parameters
ElemsNumber of elements represented in the mask.

◆ unaligned_vector_ref

template<ElemBaseType T, unsigned Elems = native_vector_length_v<T>, aie_dm_resource Resource = aie_dm_resource::none>
using aie::unaligned_vector_ref = typedef detail::unaligned_vector_ref<T, Elems, Resource>

Type for references to vector registers. The documentation of this class and its members can be found at detail::unaligned_vector_ref.

Template Parameters
TType of the elements contained in the vector. It must meet ElemBaseType.
ElemsNumber of elements in the vector.

◆ vector

template<ElemBaseType T, unsigned Elems = native_vector_length_v<T>>
using aie::vector = typedef detail::vector<T, Elems>

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

Template Parameters
TType of the elements contained in the vector. It must meet ElemBaseType.
ElemsNumber of elements in the vector.

◆ vector_elem_const_ref

template<ElemBaseType T, unsigned N>
using aie::vector_elem_const_ref = typedef detail::vector_elem_const_ref<T, N>

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

Template Parameters
TType of the elements contained in the referenced vector. It must meet ElemBaseType.
ElemsNumber of elements in the referenced vector.

◆ vector_elem_ref

template<ElemBaseType T, unsigned N>
using aie::vector_elem_ref = typedef detail::vector_elem_ref<T, N>

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
TType of the elements contained in the referenced vector. It must meet ElemBaseType.
ElemsNumber of elements in the referenced vector.

◆ vector_ref

template<ElemBaseType T, unsigned Elems = native_vector_length_v<T>, aie_dm_resource Resource = aie_dm_resource::none>
using aie::vector_ref = typedef detail::vector_ref<T, Elems, Resource>

Type for references to vector registers. The documentation of this class and its members can be found at detail::vector_ref.

Template Parameters
TType of the elements contained in the vector. It must meet ElemBaseType.
ElemsNumber of elements in the vector.