AI Engine API User Guide (AIE-API) 2025.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
Basic Types

Overview

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

Vector

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 natively. Larger vectors are also supported by transparently maintaining the required number of native vectors.

Supported vector types and native sizes
Arch. int4 uint4 int8 uint8 int16 uint16 int32 uint32 bfloat16 float cint16 cint32 cbfloat16cfloat
AIE 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
AIE-ML
XDNA 1
32/64/128/256 32/64/128/256 16/32/64/128 16/32/64/128 8/16/32/64 8/16/32/64 4/8/16/32 4/8/16/32 8/16/32/64 4/8/16/32 4/8/16/32 2/4/8/16 4/8/16/32 2/4/8/16
XDNA 2 32/64/128/256 32/64/128/256 16/32/64/128 16/32/64/128 8/16/32/64 8/16/32/64 4/8/16/32 4/8/16/32 8/16/32/64 4/8/16/32 4/8/16/32 2/4/8/16

To declare a vector, specify the desired template parameters following the vector template parameters table. The following example declares a vector variable with 32 elements of type int16:

Type for vector registers.
Definition vector.hpp:73

Refer to Basic Type Initialization for examples of how to initialize vector objects.

Accumulator

An accumulator represents a collection of elements of the same class, typically obtained as a result of a multiplication operation. They are 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 would otherwise exceed the range of regular vector types. They are parametrized by the element type (see Accumulator Element Types) and the number of elements. Element types specify the class of an element (e.g. integral, floating point, complex) and its minimum amount of bits required. AIE API then maps it to the nearest accumulator type that is supported natively. Similarly to vectors, accumulators larger than the native sizes are supported by transparently maintaining the required number of native accumulators.

Supported accumulator types and native sizes
Arch.acc32acc40acc48acc56acc64acc72acc80accfloatcacc32cacc40cacc48cacc56cacc64cacc72cacc80caccfloat
AIE Lanes 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 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 2/4/8/16
Native accumulation 48b 48b 48b 80b 80b 80b 80b 32b 48b 48b 48b 80b 80b 80b 80b 32b
AIE-ML
XDNA 1
Lanes 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/128 2/4/8/16/32 2/4/8/16/32 2/4/8/16/32 2/4/8/16/32 2/4/8/16/32 2/4/8/16/32/64
Native accumulation 32b 64b 64b 64b 64b 32b 64b 64b 64b 64b 64b 32b
XDNA 2 Lanes 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/128 2/4/8/16/32 2/4/8/16/32 2/4/8/16/32 2/4/8/16/32 2/4/8/16/32
Native accumulation 32b 64b 64b 64b 64b 32b 64b 64b 64b 64b 64b

Like vectors, declaring an accumulator consists of specifying all its template parameters, following the accumulator template parameters table for the accepted combinations when declaring accumulators. For example:

aie::accum<accfloat, 16> my_accumulator;
Type for vector accumulators.
Definition accum.hpp:49

Refer to Basic Type Initialization for examples of how to initialize accumulator objects.

Note
As mentioned in Interoperability with Adaptive Data Flow (ADF) Graph Abstractions, ADF graph code does not support non-native accumulator types.

Block Vector

A block vector represents a collection of blocked data types where several elements share some common data. Block vectors are parametrized by the element type and the number of elements, with the supported combinations on each architecture shown below.

Supported block vector types and native sizes
Arch. bfp16ebs8 bfp16ebs16
XDNA 2 32/64/128/256 32/64/128/256

To declare a block vector, specify the desired template parameters following the block vector template parameters table. The following example declares a vector variable with 64 elements of type bfp16ebs8:

aie::block_vector<bfp16ebs8, 64> my_vector;

Refer to Block Vector Buffer Streams for examples of how to load data into block vector objects.

Mask

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

aie::mask<64> my_mask;
Type for vector element masks.
Definition mask.hpp:18

Refer to Basic Type Initialization for examples of how to initialize mask objects.

Topics

 Basic Type Initialization
 
 Vector and Accumulator Conversions
 Vectors can be reinterpreted as vectors with a different element type, as long as they have the same total size.
 
 Concepts for Basic Types
 
 Accumulator Element Types
 Accumulators in AIE API rely on the aie::accum class template.
 
 Lazy Operations
 AIE architectures offer multiplication instructions that can perform additional operations on on the input arguments.
 

Classes

class  aie::accum< MinAccumTag, Elems >
 Type for vector accumulators. More...
 
class  aie::mask< Elems >
 Type for vector element masks. More...
 
class  aie::sparse_vector< T, Elems >
 Type for sparse vector registers. More...
 
class  aie::vector< T, Elems >
 Type for vector registers. More...
 
class  aie::vector_elem_const_ref< T, N >
 Reference to immutable vector element. More...
 
class  aie::vector_elem_ref< T, N >
 Reference to vector element. More...
 

Class Documentation

◆ aie::accum

class aie::accum
template<AccumElemBaseType MinAccumTag, unsigned Elems>
class aie::accum< MinAccumTag, Elems >

Type for vector accumulators.

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 aie::AccumElemBaseType.
ElemsNumber of elements in the accumulator.

Public Types

using storage_t = typename base_type::storage_t
 Type that holds the actual accumulator's data.
 
using value_type = typename base_type::value_type
 Type of the elements in the accumulator.
 

Public Member Functions

 accum ()=default
 Default constructor.
 
 accum (const accum &)=default
 Copy constructor.
 
template<AccumElemBaseType Tag2>
requires (has_same_representation<Tag2>())
 accum (const accum< Tag2, Elems > &acc)
 Copies another accumulator with the same underlying representation.
 
template<typename T>
 accum (const vector< T, Elems > &v, int shift=0)
 Construct from a vector.
 
 accum (storage_t data)
 Construct from internal storage type.
 
template<typename DstTag>
auto cast_to () const
 Reinterprets the current accumulator as an accumulator of the given type.
 
template<unsigned ElemsOut>
accum< MinAccumTag, ElemsOut > extract (unsigned idx) const
 Returns a subaccumulator with the contents of a region of the accumulator.
 
template<typename T>
void from_vector (const vector< T, Elems > &v, int shift=0)
 Updates the contents of the accumulator using the values in the given vector after applying the requested upshift operation.
 
template<typename T>
void from_vector_sign (const vector< T, Elems > &v, bool v_sign, int shift=0)
 Updates the contents of the accumulator using the values in the given vector after applying the requested upshift operation.
 
template<unsigned ElemsOut>
accum< MinAccumTag, ElemsOut > grow () const
 Returns a copy of the current accumulator in a larger accumulator.
 
template<unsigned ElemsOut>
accum< MinAccumTag, ElemsOut > grow_extract (unsigned idx) const
 Returns a copy of the accumulator with a new size.
 
template<unsigned ElemsOut>
constexpr accum< MinAccumTag, ElemsOut > grow_replicate () const
 Returns a copy of the current accumulator in a larger accumulator.
 
template<unsigned ElemsIn, AccumElemBaseType Tag2>
accuminsert (unsigned idx, const accum< Tag2, ElemsIn > &acc)
 Updates the contents of a region of the accumulator with a native subaccumulator.
 
template<NativeAccumType T2>
accuminsert (unsigned idx, T2 acc)
 Updates the contents of a region of the accumulator using the values in the given native subaccumulator.
 
template<unsigned ElemsIn>
accuminsert (unsigned idx, typename accum< MinAccumTag, ElemsIn >::storage_t acc)
 Updates the contents of a region of the accumulator using the values in the given native subaccumulator.
 
 operator storage_t () const
 Operator for conversion to the internal underlying type.
 
template<typename T>
requires (detail::accum_class_for_type_v<T> == value_class() && is_floating_point() && size() <= 32)
 operator vector< T, Elems > () const
 Performs the conversion of a FP32/CFP32 accumulator to a vector of the same type.
 
template<typename T>
accumoperator= (const vector< T, Elems > &v)
 Updates the contents of the accumulator using the values in the given vector.
 
template<unsigned ElemsOut>
auto split () const
 Returns the contents of the current accum stored in a std::tuple of subaccums.
 
auto to_native () const
 Returns the native type of the accumulator.
 
auto to_vector () const
 Returns the values of the FP32 accumulator in a vector of the requested type.
 
template<typename T>
vector< T, Elems > to_vector (int shift=0) const
 Applies shift-round-saturate to the elements of the accumulator and stores the result into a vector of the requested type, keeping the original values unchanged.
 
template<typename T>
vector< T, Elems > to_vector_sign (bool v_sign, int shift=0) const
 Applies shift-round-saturate to the elements of the accumulator and stores the result into a vector of the type and signedness requested.
 
template<typename T>
requires (arch::is(arch::AIE))
vector< T, Elems > to_vector_zip (int shift=0) const
 Permutes and applies shift-round-saturate to the elements of the accumulator.
 
template<AccumElemBaseType Tag2, unsigned E2, unsigned... Es>
requires (Elems == (E2 + (Es + ...)) && ((Elems / E2 == Elems / Es) && ...))
void upd_all (const accum< Tag2, E2 > &subacc, const accum< Tag2, Es > &...subaccums)
 Updates the contents of the accumulator using the values in the given subaccumulators.
 

Static Public Member Functions

static constexpr unsigned bits ()
 Returns the total size of the accumulator in bits.
 
static constexpr bool is_complex ()
 Returns true if the element class is a complex number.
 
static constexpr bool is_floating_point ()
 Returns true if the element class is a floating point number.
 
static constexpr bool is_real ()
 Returns true if the element class is a real number.
 
static constexpr unsigned size ()
 Returns the number of elements in the accumulator.
 
static constexpr detail::AccumClass value_class ()
 Returns the class of the accumulator elements.
 

Member Typedef Documentation

◆ storage_t

template<AccumElemBaseType MinAccumTag, unsigned Elems>
using aie::accum< MinAccumTag, Elems >::storage_t = typename base_type::storage_t

Type that holds the actual accumulator's data.

May be different to its native type.

◆ value_type

template<AccumElemBaseType MinAccumTag, unsigned Elems>
using aie::accum< MinAccumTag, Elems >::value_type = typename base_type::value_type

Type of the elements in the accumulator.

Constructor & Destructor Documentation

◆ accum() [1/5]

template<AccumElemBaseType MinAccumTag, unsigned Elems>
aie::accum< MinAccumTag, Elems >::accum ( )
default

Default constructor.

The value of the elements is undefined.

◆ accum() [2/5]

template<AccumElemBaseType MinAccumTag, unsigned Elems>
aie::accum< MinAccumTag, Elems >::accum ( const accum< MinAccumTag, Elems > & )
default

Copy constructor.

◆ accum() [3/5]

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<AccumElemBaseType Tag2>
requires (has_same_representation<Tag2>())
aie::accum< MinAccumTag, Elems >::accum ( const accum< Tag2, Elems > & acc)
inline

Copies another accumulator with the same underlying representation.

◆ accum() [4/5]

template<AccumElemBaseType MinAccumTag, unsigned Elems>
aie::accum< MinAccumTag, Elems >::accum ( storage_t data)
inline

Construct from internal storage type.

Parameters
dataData used to construct the accumulator from.

◆ accum() [5/5]

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<typename T>
aie::accum< MinAccumTag, Elems >::accum ( const vector< T, Elems > & v,
int shift = 0 )
inlineexplicit

Construct from a vector.

The accumulator class and the vector type must be compatible. The accumulator size and the vector size must be the same.

Parameters
vData used to construct the accumulator from.
shiftUpshift value.

Member Function Documentation

◆ bits()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
static constexpr unsigned aie::accum< MinAccumTag, Elems >::bits ( )
inlinestaticconstexpr

Returns the total size of the accumulator in bits.

◆ cast_to()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<typename DstTag>
auto aie::accum< MinAccumTag, Elems >::cast_to ( ) const
inline

Reinterprets the current accumulator as an accumulator of the given type.

The number of elements is automatically computed by the function

Template Parameters
DstTagType the accumulator will be cast to

◆ extract()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<unsigned ElemsOut>
accum< MinAccumTag, ElemsOut > aie::accum< MinAccumTag, Elems >::extract ( unsigned idx) const
inline

Returns a subaccumulator with the contents of a region of the accumulator.

Template Parameters
ElemsOutSize of the returned subaccumulator.
Parameters
idxIndex of the subaccumulator to be returned.

◆ from_vector()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<typename T>
void aie::accum< MinAccumTag, Elems >::from_vector ( const vector< T, Elems > & v,
int shift = 0 )
inline

Updates the contents of the accumulator using the values in the given vector after applying the requested upshift operation.

Parameters
vInput vector.
shiftNumber of bits to be upshifted.

◆ from_vector_sign()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<typename T>
void aie::accum< MinAccumTag, Elems >::from_vector_sign ( const vector< T, Elems > & v,
bool v_sign,
int shift = 0 )
inline

Updates the contents of the accumulator using the values in the given vector after applying the requested upshift operation.

Allows for dynamic control of whether the values are considered signed or not.

Note
Currently functional on AIE-ML/XDNA 1 or later architectures only.
Parameters
vInput vector.
v_signValues are considered signed or not, regardless of the underlying type.
shiftNumber of bits to be upshifted.

◆ grow()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<unsigned ElemsOut>
accum< MinAccumTag, ElemsOut > aie::accum< MinAccumTag, Elems >::grow ( ) const
inline

Returns a copy of the current accumulator in a larger accumulator.

The value of the new elements is undefined.

Template Parameters
ElemsOutSize of the output accumulator.

◆ grow_extract()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<unsigned ElemsOut>
accum< MinAccumTag, ElemsOut > aie::accum< MinAccumTag, Elems >::grow_extract ( unsigned idx) const
inline

Returns a copy of the accumulator with a new size.

  • Performs an extract(idx) operation when the new size is smaller.
  • Performs a grow() operation when the new size is bigger.
See also
grow<ElemsOut>(unsigned) const
extract<ElemsOut>(unsigned) const

◆ grow_replicate()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<unsigned ElemsOut>
accum< MinAccumTag, ElemsOut > aie::accum< MinAccumTag, Elems >::grow_replicate ( ) const
inlineconstexpr

Returns a copy of the current accumulator in a larger accumulator.

The contents of the accumulator are replicated as many times as required to fill the output accumulator

Template Parameters
ElemsOutSize of the output accumulator.

◆ insert() [1/3]

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<unsigned ElemsIn, AccumElemBaseType Tag2>
accum & aie::accum< MinAccumTag, Elems >::insert ( unsigned idx,
const accum< Tag2, ElemsIn > & acc )
inline

Updates the contents of a region of the accumulator with a native subaccumulator.

Parameters
idxIndex of the subaccumulator to be replaced.
accNative subaccumulator to be written into the region.
Returns
Reference to the updated accumulator.

◆ insert() [2/3]

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<NativeAccumType T2>
accum & aie::accum< MinAccumTag, Elems >::insert ( unsigned idx,
T2 acc )
inline

Updates the contents of a region of the accumulator using the values in the given native subaccumulator.

Parameters
idxIndex of the subaccumulator to be replaced.
accNative subaccumulator to be written into the region.
Returns
Reference to the updated accumulator.

◆ insert() [3/3]

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<unsigned ElemsIn>
accum & aie::accum< MinAccumTag, Elems >::insert ( unsigned idx,
typename accum< MinAccumTag, ElemsIn >::storage_t acc )
inline

Updates the contents of a region of the accumulator using the values in the given native subaccumulator.

Parameters
idxIndex of the subaccumulator to be replaced.
accNative subaccumulator to be written into the region.
Returns
Reference to the updated accumulator.

◆ is_complex()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
static constexpr bool aie::accum< MinAccumTag, Elems >::is_complex ( )
inlinestaticconstexpr

Returns true if the element class is a complex number.

◆ is_floating_point()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
static constexpr bool aie::accum< MinAccumTag, Elems >::is_floating_point ( )
inlinestaticconstexpr

Returns true if the element class is a floating point number.

◆ is_real()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
static constexpr bool aie::accum< MinAccumTag, Elems >::is_real ( )
inlinestaticconstexpr

Returns true if the element class is a real number.

◆ operator storage_t()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
aie::accum< MinAccumTag, Elems >::operator storage_t ( ) const
inline

Operator for conversion to the internal underlying type.

If the number of internal subaccumulators is 1, this type matches the native type.

◆ operator vector< T, Elems >()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<typename T>
requires (detail::accum_class_for_type_v<T> == value_class() && is_floating_point() && size() <= 32)
aie::accum< MinAccumTag, Elems >::operator vector< T, Elems > ( ) const
inline

Performs the conversion of a FP32/CFP32 accumulator to a vector of the same type.

◆ operator=()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<typename T>
accum & aie::accum< MinAccumTag, Elems >::operator= ( const vector< T, Elems > & v)
inline

Updates the contents of the accumulator using the values in the given vector.

No upshift is applied.

Parameters
vInput vector.

◆ size()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
static constexpr unsigned aie::accum< MinAccumTag, Elems >::size ( )
inlinestaticconstexpr

Returns the number of elements in the accumulator.

◆ split()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<unsigned ElemsOut>
auto aie::accum< MinAccumTag, Elems >::split ( ) const
inline

Returns the contents of the current accum stored in a std::tuple of subaccums.

Template Parameters
ElemsOutSize of each subaccum.

◆ to_native()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
auto aie::accum< MinAccumTag, Elems >::to_native ( ) const
inline

Returns the native type of the accumulator.

Only valid when the number of subaccumulators is 1.

◆ to_vector() [1/2]

template<AccumElemBaseType MinAccumTag, unsigned Elems>
auto aie::accum< MinAccumTag, Elems >::to_vector ( ) const
inline

Returns the values of the FP32 accumulator in a vector of the requested type.

◆ to_vector() [2/2]

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<typename T>
vector< T, Elems > aie::accum< MinAccumTag, Elems >::to_vector ( int shift = 0) const
inline

Applies shift-round-saturate to the elements of the accumulator and stores the result into a vector of the requested type, keeping the original values unchanged.

Note
On AIE-ML/XDNA 1 shift values of -4, -3, and -2 are unsafe, as they will only produce correct result if truncation is selected or saturation against 0 is required.
Parameters
shiftNumber of bits that need to be downshifted.

◆ to_vector_sign()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<typename T>
vector< T, Elems > aie::accum< MinAccumTag, Elems >::to_vector_sign ( bool v_sign,
int shift = 0 ) const
inline

Applies shift-round-saturate to the elements of the accumulator and stores the result into a vector of the type and signedness requested.

The original values are left unchanged.

Note
Currently functional on AIE-ML/XDNA 1 or later architectures only.
On AIE-ML/XDNA 1 shift values of -4, -3, and -2 are unsafe, as they will only produce correct result if truncation is selected or saturation against 0 is required.
Parameters
v_signReturned vector is signed or not, regardless of the underlying type.
shiftNumber of bits that need to be downshifted.

◆ to_vector_zip()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<typename T>
requires (arch::is(arch::AIE))
vector< T, Elems > aie::accum< MinAccumTag, Elems >::to_vector_zip ( int shift = 0) const
inline

Permutes and applies shift-round-saturate to the elements of the accumulator.

Then, it stores the result into a vector of the requested type.

The original values are left unchanged.

The values are interleaved as if the accumulator were split in two parts and zipped.

Parameters
shiftNumber of bits that need to be downshifted.

◆ upd_all()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<AccumElemBaseType Tag2, unsigned E2, unsigned... Es>
requires (Elems == (E2 + (Es + ...)) && ((Elems / E2 == Elems / Es) && ...))
void aie::accum< MinAccumTag, Elems >::upd_all ( const accum< Tag2, E2 > & subacc,
const accum< Tag2, Es > &... subaccums )
inline

Updates the contents of the accumulator using the values in the given subaccumulators.

Subaccumulators must be of the same class and size.

Parameters
subaccFirst sub-accumulator.
subaccumsRemaining sub-accumulators.

◆ value_class()

template<AccumElemBaseType MinAccumTag, unsigned Elems>
static constexpr detail::AccumClass aie::accum< MinAccumTag, Elems >::value_class ( )
inlinestaticconstexpr

Returns the class of the accumulator elements.

Friends And Related Symbol Documentation

◆ accum

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<AccumElemBaseType Tag2, unsigned E2>
friend class accum
friend

◆ accum_base

template<AccumElemBaseType MinAccumTag, unsigned Elems>
template<detail::AccumClass Class, unsigned MinBits, unsigned E2>
friend class accum_base
friend

◆ aie::mask

class aie::mask
template<unsigned Elems>
class aie::mask< Elems >

Type for vector element masks.

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

Template Parameters
ElemsNumber of elements represented in the mask.

Public Member Functions

constexpr mask (bool initial_set=false)
 Creates a mask.
 
template<typename... T>
constexpr mask (unsigned w, T &&... words)
 Construct from unsigned (32b) words.
 
constexpr void clear (unsigned i)
 Sets the value of the element in the given index to 0.
 
constexpr unsigned clz () const
 Returns the count of consecutive elements, starting at the high part of the mask, whose value is 0.
 
constexpr unsigned count () const
 Returns the count of elements whose value is 1.
 
constexpr const std::array< unsigned, num_words > & data () const
 
constexpr bool empty () const
 Returns a bool that says whether the value of all the elements in the mask is 0.
 
template<unsigned ElemsOut>
constexpr mask< ElemsOut > extract (unsigned idx) const
 Returns the contents of a section of the mask into a smaller mask.
 
constexpr bool full () const
 Returns a bool that says whether the value of all the elements in the mask is 1.
 
template<unsigned ElemsOut>
constexpr mask< ElemsOut > get_submask (unsigned idx) const
 Returns the contents of a section of the mask into a smaller mask.
 
template<unsigned ElemsIn>
constexpr maskinsert (unsigned idx, const mask< ElemsIn > &m)
 Updates the contents of a region of the mask.
 
constexpr mask operator& (const mask &a) const
 Returns the result of merging the current and the given masks using the AND operation.
 
constexpr maskoperator&= (const mask &a)
 Updates the mask with the result of merging the current with the given masks using the AND operation.
 
constexpr mask operator<< (unsigned shift) const
 Returns the result of a binary left shift of the mask.
 
constexpr maskoperator<<= (unsigned shift)
 Returns the result of a binary left shift of the mask.
 
constexpr bool operator== (const mask &a) const
 Compares whether two masks are equal.
 
constexpr mask operator>> (unsigned shift) const
 Returns the result of a binary right shift of the mask.
 
constexpr maskoperator>>= (unsigned shift)
 Returns the result of a binary right shift of the mask.
 
constexpr mask operator| (const mask &a) const
 Returns the result of merging the current and the given masks using the OR operation.
 
constexpr maskoperator|= (const mask &a)
 Updates the mask with the result of merging the current and the given masks using the OR operation.
 
constexpr mask operator~ () const
 Returns a mask that contains the negation of the values of all the elements in the mask (0->1, 1->0).
 
constexpr void set (unsigned i)
 Sets the value of the element in the given index to 1.
 
constexpr bool test (unsigned i) const
 Returns the value of the element in the given index.
 
template<unsigned Elems2 = Elems>
requires (Elems2 <= 32)
constexpr unsigned to_uint32 () const
 Returns the contents of the mask in a 32b unsigned integer.
 
constexpr unsigned to_uint32 (unsigned i) const
 Returns the contents of a section of the mask in a 32b unsigned integer.
 
template<unsigned Elems2 = Elems>
requires (Elems2 == 64)
constexpr uint64_t to_uint64 () const
 Returns the contents of the mask in a 64b unsigned integer.
 
constexpr uint64_t to_uint64 (unsigned i) const
 Returns the contents of a section of the mask in a 64b unsigned integer.
 

Static Public Member Functions

template<unsigned E, unsigned... Es>
requires (Elems == (E + (Es + ...)) && ((E == Es) && ...))
static constexpr mask< Elems > from_masks (const mask< E > &m, const mask< Es > &... masks)
 Construct from concatenating multiple smaller masks.
 
template<typename... T>
static constexpr mask< Elems > from_uint32 (unsigned w, T &&... words)
 Construct from unsigned (32b) words.
 
template<typename... T>
static constexpr mask< Elems > from_uint64 (uint64_t w, T &&... words)
 Construct from unsigned (64b) words.
 
static constexpr unsigned size ()
 Returns the number of elements in the mask.
 

Constructor & Destructor Documentation

◆ mask() [1/2]

template<unsigned Elems>
aie::mask< Elems >::mask ( bool initial_set = false)
inlineexplicitconstexpr

Creates a mask.

Parameters
initial_setIf true, the mask is initialized with 1s, otherise it is initialized with 0s.

◆ mask() [2/2]

template<unsigned Elems>
template<typename... T>
aie::mask< Elems >::mask ( unsigned w,
T &&... words )
inlineexplicitconstexpr

Construct from unsigned (32b) words.

Each bit in the input words is used to initialize one of the elements in the mask.

Parameters
wFirst word used to initialize the mask.
wordsRest of words used to initialize the mask.

Member Function Documentation

◆ clear()

template<unsigned Elems>
void aie::mask< Elems >::clear ( unsigned i)
inlineconstexpr

Sets the value of the element in the given index to 0.

Parameters
iElement index.

◆ clz()

template<unsigned Elems>
unsigned aie::mask< Elems >::clz ( ) const
inlineconstexpr

Returns the count of consecutive elements, starting at the high part of the mask, whose value is 0.

◆ count()

template<unsigned Elems>
unsigned aie::mask< Elems >::count ( ) const
inlineconstexpr

Returns the count of elements whose value is 1.

◆ data()

template<unsigned Elems>
const std::array< unsigned, num_words > & aie::mask< Elems >::data ( ) const
inlineconstexpr
Deprecated
Use alternative functions to access the elements of a mask.
See also
to_uint32, to_uint64, get_submask

◆ empty()

template<unsigned Elems>
bool aie::mask< Elems >::empty ( ) const
inlineconstexpr

Returns a bool that says whether the value of all the elements in the mask is 0.

◆ extract()

template<unsigned Elems>
template<unsigned ElemsOut>
mask< ElemsOut > aie::mask< Elems >::extract ( unsigned idx) const
inlineconstexpr

Returns the contents of a section of the mask into a smaller mask.

Template Parameters
ElemsOutSize of the returned mask
Parameters
idxIndex of the section within the mask (in chunks of ElemsOut elements)

◆ from_masks()

template<unsigned Elems>
template<unsigned E, unsigned... Es>
requires (Elems == (E + (Es + ...)) && ((E == Es) && ...))
static constexpr mask< Elems > aie::mask< Elems >::from_masks ( const mask< E > & m,
const mask< Es > &... masks )
inlinestaticconstexpr

Construct from concatenating multiple smaller masks.

Parameters
mFirst mask used to initialize least significant elements in the new mask.
masksOther masks used to initialize the rest of the elements.

◆ from_uint32()

template<unsigned Elems>
template<typename... T>
static constexpr mask< Elems > aie::mask< Elems >::from_uint32 ( unsigned w,
T &&... words )
inlinestaticconstexpr

Construct from unsigned (32b) words.

Each bit in the input words is used to initialize one of the elements in the mask.

Parameters
wFirst word used to initialize the mask.
wordsRest of words used to initialize the mask.

◆ from_uint64()

template<unsigned Elems>
template<typename... T>
static constexpr mask< Elems > aie::mask< Elems >::from_uint64 ( uint64_t w,
T &&... words )
inlinestaticconstexpr

Construct from unsigned (64b) words.

Each bit in the input words is used to initialize one of the elements in the mask.

Parameters
wFirst word used to initialize the mask.
wordsRest of words used to initialize the mask.

◆ full()

template<unsigned Elems>
bool aie::mask< Elems >::full ( ) const
inlineconstexpr

Returns a bool that says whether the value of all the elements in the mask is 1.

◆ get_submask()

template<unsigned Elems>
template<unsigned ElemsOut>
mask< ElemsOut > aie::mask< Elems >::get_submask ( unsigned idx) const
inlineconstexpr

Returns the contents of a section of the mask into a smaller mask.

Template Parameters
ElemsOutSize of the returned mask
Parameters
idxIndex of the section within the mask (in chunks of ElemsOut elements)

◆ insert()

template<unsigned Elems>
template<unsigned ElemsIn>
mask & aie::mask< Elems >::insert ( unsigned idx,
const mask< ElemsIn > & m )
inlineconstexpr

Updates the contents of a region of the mask.

The updated region will contain the values in the given submask.

Parameters
idxIndex of the submask to be replaced.
mSubmask to be written into the region.
Returns
a reference to the updated mask.

◆ operator&()

template<unsigned Elems>
mask aie::mask< Elems >::operator& ( const mask< Elems > & a) const
inlineconstexpr

Returns the result of merging the current and the given masks using the AND operation.

Parameters
aMask to merge with.

◆ operator&=()

template<unsigned Elems>
mask & aie::mask< Elems >::operator&= ( const mask< Elems > & a)
inlineconstexpr

Updates the mask with the result of merging the current with the given masks using the AND operation.

Returns a reference to the updated mask.

Parameters
aMask to merge with.

◆ operator<<()

template<unsigned Elems>
mask aie::mask< Elems >::operator<< ( unsigned shift) const
inlineconstexpr

Returns the result of a binary left shift of the mask.

Parameters
shiftNumber of positions to shift the mask.

◆ operator<<=()

template<unsigned Elems>
mask & aie::mask< Elems >::operator<<= ( unsigned shift)
inlineconstexpr

Returns the result of a binary left shift of the mask.

Returns a reference to the updated mask.

Parameters
shiftNumber of positions to shift the mask.

◆ operator==()

template<unsigned Elems>
bool aie::mask< Elems >::operator== ( const mask< Elems > & a) const
inlineconstexpr

Compares whether two masks are equal.

Parameters
aMask to compare against.

◆ operator>>()

template<unsigned Elems>
mask aie::mask< Elems >::operator>> ( unsigned shift) const
inlineconstexpr

Returns the result of a binary right shift of the mask.

Parameters
shiftNumber of positions to shift the mask.

◆ operator>>=()

template<unsigned Elems>
mask & aie::mask< Elems >::operator>>= ( unsigned shift)
inlineconstexpr

Returns the result of a binary right shift of the mask.

Returns a reference to the updated mask.

Parameters
shiftNumber of positions to shift the mask.

◆ operator|()

template<unsigned Elems>
mask aie::mask< Elems >::operator| ( const mask< Elems > & a) const
inlineconstexpr

Returns the result of merging the current and the given masks using the OR operation.

Parameters
aMask to merge with.

◆ operator|=()

template<unsigned Elems>
mask & aie::mask< Elems >::operator|= ( const mask< Elems > & a)
inlineconstexpr

Updates the mask with the result of merging the current and the given masks using the OR operation.

Returns a reference to the updated mask.

Parameters
aMask to merge with.

◆ operator~()

template<unsigned Elems>
mask aie::mask< Elems >::operator~ ( ) const
inlineconstexpr

Returns a mask that contains the negation of the values of all the elements in the mask (0->1, 1->0).

◆ set()

template<unsigned Elems>
void aie::mask< Elems >::set ( unsigned i)
inlineconstexpr

Sets the value of the element in the given index to 1.

Parameters
iElement index.

◆ size()

template<unsigned Elems>
static constexpr unsigned aie::mask< Elems >::size ( )
inlinestaticconstexpr

Returns the number of elements in the mask.

◆ test()

template<unsigned Elems>
bool aie::mask< Elems >::test ( unsigned i) const
inlineconstexpr

Returns the value of the element in the given index.

Parameters
iElement index.

◆ to_uint32() [1/2]

template<unsigned Elems>
template<unsigned Elems2 = Elems>
requires (Elems2 <= 32)
unsigned aie::mask< Elems >::to_uint32 ( ) const
inlineconstexpr

Returns the contents of the mask in a 32b unsigned integer.

◆ to_uint32() [2/2]

template<unsigned Elems>
unsigned aie::mask< Elems >::to_uint32 ( unsigned i) const
inlineconstexpr

Returns the contents of a section of the mask in a 32b unsigned integer.

Parameters
iIndex of the section within the mask (in chunks of 32 elements)

◆ to_uint64() [1/2]

template<unsigned Elems>
template<unsigned Elems2 = Elems>
requires (Elems2 == 64)
uint64_t aie::mask< Elems >::to_uint64 ( ) const
inlineconstexpr

Returns the contents of the mask in a 64b unsigned integer.

◆ to_uint64() [2/2]

template<unsigned Elems>
uint64_t aie::mask< Elems >::to_uint64 ( unsigned i) const
inlineconstexpr

Returns the contents of a section of the mask in a 64b unsigned integer.

Parameters
iIndex of the section within th mask (in chunks of 64 elements)

Friends And Related Symbol Documentation

◆ mask

template<unsigned Elems>
template<unsigned Elems2>
friend class mask
friend

◆ aie::sparse_vector

class aie::sparse_vector
template<ElemBaseType T, unsigned Elems>
requires (arch::is(arch::Gen2))
class aie::sparse_vector< T, Elems >

Type for sparse vector registers.

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

Public Types

using native_pointer_type = typename vector_storage_type::pointer_type
 Intrinsic type of pointers referring to data stored in sparse format.
 
using native_type = detail::native_sparse_vector_type_t<T, Elems>
 Equivalent intrinsic type for the same element type and size.
 
using storage_t = typename vector_storage_type::type
 Type that holds the actual sparse_vector's data.
 
using value_type = T
 Type of the elements in the sparse_vector.
 
using vector_storage_type = detail::sparse_vector_storage<T, Elems>
 

Public Member Functions

 sparse_vector ()=default
 Default constructor.
 
 sparse_vector (const storage_t &data)
 Construct a sparse_vector from internal native types.
 
template<unsigned Elems2>
requires (Elems2 == Elems / 2)
sparse_vector< T, Elems2 > extract (unsigned idx) const
 Returns a subvector with the contents of a region of the sparse_vector.
 
vector< T, Elems/2 > extract_data () const =delete
 Returns an aie::vector containing partially decompressed sparse values.
 
value_type get (unsigned idx) const
 Returns the value of the element on the given index.
 
template<unsigned ElemsIn>
requires (ElemsIn == Elems / 2 || ElemsIn == Elems)
sparse_vectorinsert (unsigned idx, const sparse_vector< T, ElemsIn > &v)
 Updates the contents of a region of the sparse_vector.
 
 operator native_type () const
 Returns the value of the vector using its native type.
 

Static Public Member Functions

static constexpr unsigned bits ()
 
static constexpr unsigned bytes ()
 
static constexpr bool is_complex ()
 Returns true if the element type is a complex number.
 
static constexpr bool is_floating_point ()
 Returns true if the element type is floating-point.
 
static constexpr bool is_integral ()
 Returns true if the element type is an integer.
 
static constexpr bool is_signed ()
 Returns true if the element type is signed.
 
static constexpr unsigned memory_bytes ()
 
static constexpr unsigned size ()
 Returns the number of elements in the vector.
 
static constexpr unsigned sparsity_ratio ()
 

Member Typedef Documentation

◆ native_pointer_type

template<ElemBaseType T, unsigned Elems>
using aie::sparse_vector< T, Elems >::native_pointer_type = typename vector_storage_type::pointer_type

Intrinsic type of pointers referring to data stored in sparse format.

◆ native_type

template<ElemBaseType T, unsigned Elems>
using aie::sparse_vector< T, Elems >::native_type = detail::native_sparse_vector_type_t<T, Elems>

Equivalent intrinsic type for the same element type and size.

◆ storage_t

template<ElemBaseType T, unsigned Elems>
using aie::sparse_vector< T, Elems >::storage_t = typename vector_storage_type::type

Type that holds the actual sparse_vector's data.

May be different to its native type.

◆ value_type

template<ElemBaseType T, unsigned Elems>
using aie::sparse_vector< T, Elems >::value_type = T

Type of the elements in the sparse_vector.

◆ vector_storage_type

template<ElemBaseType T, unsigned Elems>
using aie::sparse_vector< T, Elems >::vector_storage_type = detail::sparse_vector_storage<T, Elems>

Constructor & Destructor Documentation

◆ sparse_vector() [1/2]

template<ElemBaseType T, unsigned Elems>
aie::sparse_vector< T, Elems >::sparse_vector ( )
default

Default constructor.

The value of the elements is undefined.

◆ sparse_vector() [2/2]

template<ElemBaseType T, unsigned Elems>
aie::sparse_vector< T, Elems >::sparse_vector ( const storage_t & data)
inline

Construct a sparse_vector from internal native types.

Parameters
dataData used to construct the vector from.

Member Function Documentation

◆ bits()

template<ElemBaseType T, unsigned Elems>
static constexpr unsigned aie::sparse_vector< T, Elems >::bits ( )
inlinestaticconstexpr

◆ bytes()

template<ElemBaseType T, unsigned Elems>
static constexpr unsigned aie::sparse_vector< T, Elems >::bytes ( )
inlinestaticconstexpr

◆ extract()

template<ElemBaseType T, unsigned Elems>
template<unsigned Elems2>
requires (Elems2 == Elems / 2)
sparse_vector< T, Elems2 > aie::sparse_vector< T, Elems >::extract ( unsigned idx) const
inline

Returns a subvector with the contents of a region of the sparse_vector.

Template Parameters
ElemsOutSize of the returned subvector.
Parameters
idxIndex of the subvector to be returned.

◆ extract_data()

template<ElemBaseType T, unsigned Elems>
vector< T, Elems/2 > aie::sparse_vector< T, Elems >::extract_data ( ) const
delete

Returns an aie::vector containing partially decompressed sparse values.

◆ get()

template<ElemBaseType T, unsigned Elems>
value_type aie::sparse_vector< T, Elems >::get ( unsigned idx) const
inline

Returns the value of the element on the given index.

Warning
Currently not implemented.
Parameters
idxIndex of the element.

◆ insert()

template<ElemBaseType T, unsigned Elems>
template<unsigned ElemsIn>
requires (ElemsIn == Elems / 2 || ElemsIn == Elems)
sparse_vector & aie::sparse_vector< T, Elems >::insert ( unsigned idx,
const sparse_vector< T, ElemsIn > & v )
inline

Updates the contents of a region of the sparse_vector.

The updated region will contain the values in the given subvector.

Parameters
idxIndex of the subvector to be replaced.
vSubvector to be written into the region.
Returns
a reference to the updated vector.

◆ is_complex()

template<ElemBaseType T, unsigned Elems>
static constexpr bool aie::sparse_vector< T, Elems >::is_complex ( )
inlinestaticconstexpr

Returns true if the element type is a complex number.

◆ is_floating_point()

template<ElemBaseType T, unsigned Elems>
static constexpr bool aie::sparse_vector< T, Elems >::is_floating_point ( )
inlinestaticconstexpr

Returns true if the element type is floating-point.

◆ is_integral()

template<ElemBaseType T, unsigned Elems>
static constexpr bool aie::sparse_vector< T, Elems >::is_integral ( )
inlinestaticconstexpr

Returns true if the element type is an integer.

◆ is_signed()

template<ElemBaseType T, unsigned Elems>
static constexpr bool aie::sparse_vector< T, Elems >::is_signed ( )
inlinestaticconstexpr

Returns true if the element type is signed.

◆ memory_bytes()

template<ElemBaseType T, unsigned Elems>
static constexpr unsigned aie::sparse_vector< T, Elems >::memory_bytes ( )
inlinestaticconstexpr

◆ operator native_type()

template<ElemBaseType T, unsigned Elems>
aie::sparse_vector< T, Elems >::operator native_type ( ) const
inline

Returns the value of the vector using its native type.

◆ size()

template<ElemBaseType T, unsigned Elems>
static constexpr unsigned aie::sparse_vector< T, Elems >::size ( )
inlinestaticconstexpr

Returns the number of elements in the vector.

◆ sparsity_ratio()

template<ElemBaseType T, unsigned Elems>
static constexpr unsigned aie::sparse_vector< T, Elems >::sparsity_ratio ( )
inlinestaticconstexpr

Friends And Related Symbol Documentation

◆ sparse_vector

template<ElemBaseType T, unsigned Elems>
template<ElemBaseType T2, unsigned Elems2>
friend class sparse_vector
friend

◆ aie::vector

class aie::vector
template<ElemBaseType T, unsigned Elems>
class aie::vector< T, Elems >

Type for vector registers.

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

Public Types

using native_type = typename base_type::native_type
 Equivalent intrinsic type for the same element type and size.
 
using storage_t = typename base_type::storage_t
 Type that holds the actual vector's data.
 
using value_type = typename base_type::value_type
 Type of the elements in the vector.
 

Public Member Functions

 vector ()
 Default constructor.
 
 vector (const native_type &v)
 Construct from internal types.
 
 vector (storage_t v)
 Construct a vector from internal native types.
 
template<typename... Values>
 vector (value_type v, Values &&... values)
 Construct from a list of values.
 
template<typename DstT>
auto cast_to () const
 Reinterprets the current vector as a vector of the given type.
 
constexpr vector_elem_const_ref< value_type, Elems > elem_const_ref (unsigned idx) const
 Returns a constant reference object to the element on the given index.
 
constexpr vector_elem_ref< value_type, Elems > elem_ref (unsigned idx)
 Returns a reference object to the element on the given index.
 
constexpr vector_elem_const_ref< value_type, Elems > elem_ref (unsigned idx) const
 Returns a constant reference object to the element on the given index.
 
template<unsigned ElemsOut>
vector< value_type, ElemsOut > extract (unsigned idx) const
 Returns a subvector with the contents of a region of the vector.
 
value_type get (unsigned idx) const
 Returns the value of the element on the given index.
 
template<unsigned ElemsOut>
constexpr vector< T, ElemsOut > grow (unsigned idx=0) const
 Returns a copy of the current vector in a larger vector.
 
template<unsigned ElemsOut>
vector< value_type, ElemsOut > grow_extract (unsigned idx) const
 Returns a copy of the current vector in a new size.
 
template<unsigned ElemsOut>
constexpr vector< T, ElemsOut > grow_replicate () const
 Returns a copy of the current vector in a larger vector.
 
template<unsigned ElemsIn>
vectorinsert (unsigned idx, const vector< T, ElemsIn > &v)
 Updates the contents of a region of the vector.
 
template<NativeVectorType T2>
vectorinsert (unsigned idx, T2 v)
 Updates the contents of a region of the vector using.
 
template<unsigned ElemsIn>
vectorinsert (unsigned idx, typename vector< T, ElemsIn >::native_type v)
 Updates the contents of a region of the vector using.
 
template<aie_dm_resource Resource = aie_dm_resource::none, typename T2>
requires (std::is_same_v<aie_dm_resource_remove_t<T2>, value_type>)
void load (const T2 *ptr)
 Replaces the contents of the vector with the values pointed by the given memory address.
 
template<aie_dm_resource Resource = aie_dm_resource::none, typename T2>
requires (std::is_same_v<aie_dm_resource_remove_t<T2>, value_type>)
void load_unaligned (const T2 *ptr, unsigned aligned_elems)
 Replaces the contents of the vector with the values pointed by the given memory address.
 
 operator native_type () const
 Operator for conversion to the native type.
 
constexpr vector_elem_ref< value_type, Elems > operator[] (unsigned idx)
 Returns a reference object to the element on the given index.
 
constexpr vector_elem_const_ref< value_type, Elems > operator[] (unsigned idx) const
 Returns a constant reference object to the element on the given index.
 
template<PackableFrom< T > T2 = typename detail::packed_type<T>::type>
auto pack () const -> vector< T2, Elems >
 Returns a copy of the vector with elements represented in a narrower type.
 
template<PackableFrom< T > T2 = typename detail::packed_type<T>::type>
auto pack_sign (bool v_sign) const -> vector< T2, Elems >
 Returns a copy of the vector with elements represented in a narrower type, with dynamic selection of whether vectors are signed or not.
 
vectorpush (value_type v)
 Adds a new element to the vector, moving existing elements one position up.
 
void set (value_type v, unsigned idx)
 Updates the value of the element on the given index.
 
template<unsigned ElemsOut>
auto split () const -> auto
 Returns the contents of the current vector stored in a std::tuple of subvectors.
 
template<aie_dm_resource Resource = aie_dm_resource::none, typename T2>
requires (std::is_same_v<aie_dm_resource_remove_t<T2>, value_type>)
void store (T2 *ptr) const
 Writes the contents of the vector into the given memory address.
 
template<aie_dm_resource Resource = aie_dm_resource::none, typename T2>
requires (std::is_same_v<aie_dm_resource_remove_t<T2>, value_type>)
void store_unaligned (T2 *ptr, unsigned aligned_elems) const
 Writes the contents of the vector into the given memory address.
 
native_type to_native () const
 Returns the value of the vector using its native type.
 
template<UnpackableFrom< T > T2 = typename detail::unpacked_type<T>::type>
auto unpack () const -> vector< T2, Elems >
 Returns a copy of the vector with elements represented in a wider type.
 
template<UnpackableFrom< T > T2 = typename detail::unpacked_type<T>::type>
auto unpack_sign (bool v_sign) const -> vector< T2, Elems >
 Returns a copy of the vector with elements represented in a wider type, with dynamic selection of whether vectors are signed or not.
 
template<typename... SubVectors>
vectorupd_all (SubVectors &&...subvectors)
 Updates the contents of the vector using the values in the given subvectors.
 

Static Public Member Functions

static constexpr unsigned bits ()
 Returns the total size of the vector in bits.
 
static constexpr unsigned bytes ()
 Returns the total capacity of the vector in bytes.
 
static constexpr bool is_complex ()
 Returns true if the element type is a complex number.
 
static constexpr bool is_floating_point ()
 Returns true if the element type is floating-point.
 
static constexpr bool is_integral ()
 Returns true if the element type is an integer.
 
static constexpr bool is_real ()
 Returns true if the element type is a real number.
 
static constexpr bool is_signed ()
 Returns true if the element type is signed.
 
static constexpr unsigned size ()
 Returns the number of elements in the vector.
 

Member Typedef Documentation

◆ native_type

template<ElemBaseType T, unsigned Elems>
using aie::vector< T, Elems >::native_type = typename base_type::native_type

Equivalent intrinsic type for the same element type and size.

◆ storage_t

template<ElemBaseType T, unsigned Elems>
using aie::vector< T, Elems >::storage_t = typename base_type::storage_t

Type that holds the actual vector's data.

May be different to its native type.

◆ value_type

template<ElemBaseType T, unsigned Elems>
using aie::vector< T, Elems >::value_type = typename base_type::value_type

Type of the elements in the vector.

Constructor & Destructor Documentation

◆ vector() [1/4]

template<ElemBaseType T, unsigned Elems>
aie::vector< T, Elems >::vector ( )
inline

Default constructor.

The value of the elements is undefined.

◆ vector() [2/4]

template<ElemBaseType T, unsigned Elems>
aie::vector< T, Elems >::vector ( storage_t v)
inline

Construct a vector from internal native types.

Parameters
vData used to construct the vector from.

◆ vector() [3/4]

template<ElemBaseType T, unsigned Elems>
aie::vector< T, Elems >::vector ( const native_type & v)
inline

Construct from internal types.

This is a special case for 1024b internal vector types, which need to be broken into two 512b vectors

Parameters
vData used to construct the vector from

◆ vector() [4/4]

template<ElemBaseType T, unsigned Elems>
template<typename... Values>
aie::vector< T, Elems >::vector ( value_type v,
Values &&... values )
inlineexplicit

Construct from a list of values.

Parameters
vFirst value in the list
valuesRest of values in the list

Member Function Documentation

◆ bits()

template<ElemBaseType T, unsigned Elems>
static constexpr unsigned aie::vector< T, Elems >::bits ( )
inlinestaticconstexpr

Returns the total size of the vector in bits.

◆ bytes()

template<ElemBaseType T, unsigned Elems>
static constexpr unsigned aie::vector< T, Elems >::bytes ( )
inlinestaticconstexpr

Returns the total capacity of the vector in bytes.

◆ cast_to()

template<ElemBaseType T, unsigned Elems>
template<typename DstT>
auto aie::vector< T, Elems >::cast_to ( ) const
inline

Reinterprets the current vector as a vector of the given type.

The number of elements is automatically computed by the function

Template Parameters
DstTType the vector will be cast to

◆ elem_const_ref()

template<ElemBaseType T, unsigned Elems>
vector_elem_const_ref< value_type, Elems > aie::vector< T, Elems >::elem_const_ref ( unsigned idx) const
inlineconstexpr

Returns a constant reference object to the element on the given index.

Parameters
idxIndex of the element.

◆ elem_ref() [1/2]

template<ElemBaseType T, unsigned Elems>
vector_elem_ref< value_type, Elems > aie::vector< T, Elems >::elem_ref ( unsigned idx)
inlineconstexpr

Returns a reference object to the element on the given index.

Parameters
idxIndex of the element.

◆ elem_ref() [2/2]

template<ElemBaseType T, unsigned Elems>
vector_elem_const_ref< value_type, Elems > aie::vector< T, Elems >::elem_ref ( unsigned idx) const
inlineconstexpr

Returns a constant reference object to the element on the given index.

Parameters
idxIndex of the element.

◆ extract()

template<ElemBaseType T, unsigned Elems>
template<unsigned ElemsOut>
vector< value_type, ElemsOut > aie::vector< T, Elems >::extract ( unsigned idx) const
inline

Returns a subvector with the contents of a region of the vector.

Template Parameters
ElemsOutSize of the returned subvector.
Parameters
idxIndex of the subvector to be returned.

◆ get()

template<ElemBaseType T, unsigned Elems>
value_type aie::vector< T, Elems >::get ( unsigned idx) const
inline

Returns the value of the element on the given index.

Parameters
idxIndex of the element.

◆ grow()

template<ElemBaseType T, unsigned Elems>
template<unsigned ElemsOut>
vector< T, ElemsOut > aie::vector< T, Elems >::grow ( unsigned idx = 0) const
inlineconstexpr

Returns a copy of the current vector in a larger vector.

The value of the new elements is undefined.

Template Parameters
ElemsOutSize of the output vector.
Parameters
idxLocation of the subvector within the output vector

◆ grow_extract()

template<ElemBaseType T, unsigned Elems>
template<unsigned ElemsOut>
vector< value_type, ElemsOut > aie::vector< T, Elems >::grow_extract ( unsigned idx) const
inline

Returns a copy of the current vector in a new size.

  • Performs an extract(idx) operation when the new size is smaller.
  • Performs a grow(idx) operation when the new size is bigger.
See also
grow<ElemsOut>(unsigned) const
extract<ElemsOut>(unsigned) const

◆ grow_replicate()

template<ElemBaseType T, unsigned Elems>
template<unsigned ElemsOut>
vector< T, ElemsOut > aie::vector< T, Elems >::grow_replicate ( ) const
inlineconstexpr

Returns a copy of the current vector in a larger vector.

The contents of the vector are replicated as many times as required to fill the output vector

Template Parameters
ElemsOutSize of the output vector.

◆ insert() [1/3]

template<ElemBaseType T, unsigned Elems>
template<unsigned ElemsIn>
vector & aie::vector< T, Elems >::insert ( unsigned idx,
const vector< T, ElemsIn > & v )
inline

Updates the contents of a region of the vector.

The updated region will contain the values in the given subvector.

Parameters
idxIndex of the subvector to be replaced.
vSubvector to be written into the region.
Returns
a reference to the updated vector.

◆ insert() [2/3]

template<ElemBaseType T, unsigned Elems>
template<NativeVectorType T2>
vector & aie::vector< T, Elems >::insert ( unsigned idx,
T2 v )
inline

Updates the contents of a region of the vector using.

The updated region will contain the values in the given native subvector.

Parameters
idxIndex of the subvector to be replaced.
vNative subvector to be written into the region.
Returns
a reference to the updated vector.

◆ insert() [3/3]

template<ElemBaseType T, unsigned Elems>
template<unsigned ElemsIn>
vector & aie::vector< T, Elems >::insert ( unsigned idx,
typename vector< T, ElemsIn >::native_type v )
inline

Updates the contents of a region of the vector using.

The updated region will contain the values in the given native subvector.

Parameters
idxIndex of the subvector to be replaced.
vNative subvector to be written into the region.
Returns
a reference to the updated vector.

◆ is_complex()

template<ElemBaseType T, unsigned Elems>
static constexpr bool aie::vector< T, Elems >::is_complex ( )
inlinestaticconstexpr

Returns true if the element type is a complex number.

◆ is_floating_point()

template<ElemBaseType T, unsigned Elems>
static constexpr bool aie::vector< T, Elems >::is_floating_point ( )
inlinestaticconstexpr

Returns true if the element type is floating-point.

◆ is_integral()

template<ElemBaseType T, unsigned Elems>
static constexpr bool aie::vector< T, Elems >::is_integral ( )
inlinestaticconstexpr

Returns true if the element type is an integer.

◆ is_real()

template<ElemBaseType T, unsigned Elems>
static constexpr bool aie::vector< T, Elems >::is_real ( )
inlinestaticconstexpr

Returns true if the element type is a real number.

◆ is_signed()

template<ElemBaseType T, unsigned Elems>
static constexpr bool aie::vector< T, Elems >::is_signed ( )
inlinestaticconstexpr

Returns true if the element type is signed.

◆ load()

template<ElemBaseType T, unsigned Elems>
template<aie_dm_resource Resource = aie_dm_resource::none, typename T2>
requires (std::is_same_v<aie_dm_resource_remove_t<T2>, value_type>)
void aie::vector< T, Elems >::load ( const T2 * ptr)
inline

Replaces the contents of the vector with the values pointed by the given memory address.

Address is assumed to meet the alignment requirements for vector loads (>= 32 bytes).

Parameters
ptrPointer to the location of the values in memory.

◆ load_unaligned()

template<ElemBaseType T, unsigned Elems>
template<aie_dm_resource Resource = aie_dm_resource::none, typename T2>
requires (std::is_same_v<aie_dm_resource_remove_t<T2>, value_type>)
void aie::vector< T, Elems >::load_unaligned ( const T2 * ptr,
unsigned aligned_elems )
inline

Replaces the contents of the vector with the values pointed by the given memory address.

Address is assumed to be aligned to the given amount of elements.

Parameters
ptrPointer to the location of the values in memory.
aligned_elemsNumber of elements ptr is aligned to.

◆ operator native_type()

template<ElemBaseType T, unsigned Elems>
aie::vector< T, Elems >::operator native_type ( ) const
inline

Operator for conversion to the native type.

◆ operator[]() [1/2]

template<ElemBaseType T, unsigned Elems>
vector_elem_ref< value_type, Elems > aie::vector< T, Elems >::operator[] ( unsigned idx)
inlineconstexpr

Returns a reference object to the element on the given index.

Parameters
idxIndex of the element.

◆ operator[]() [2/2]

template<ElemBaseType T, unsigned Elems>
vector_elem_const_ref< value_type, Elems > aie::vector< T, Elems >::operator[] ( unsigned idx) const
inlineconstexpr

Returns a constant reference object to the element on the given index.

Parameters
idxIndex of the element.

◆ pack()

template<ElemBaseType T, unsigned Elems>
template<PackableFrom< T > T2>
auto aie::vector< T, Elems >::pack ( ) const -> vector<T2, Elems>
inline

Returns a copy of the vector with elements represented in a narrower type.

By default, packing a vector will produce a vector with half the number of bits. For example, packing a vector of 16b elements will produce a vector of 8b elements.

Note
Only vectors with integer elements are allowed.
Complex vectors can only unpack to other complex types.
Template Parameters
T2target element type. It must be narrower than the vector's element type.

◆ pack_sign()

template<ElemBaseType T, unsigned Elems>
template<PackableFrom< T > T2>
auto aie::vector< T, Elems >::pack_sign ( bool v_sign) const -> vector<T2, Elems>
inline

Returns a copy of the vector with elements represented in a narrower type, with dynamic selection of whether vectors are signed or not.

By default, packing a vector will produce a vector with half the number of bits. For example, packing a vector of 16b elements will produce a vector of 8b elements.

Note
Only vectors with integer elements are allowed.
Complex vectors can only unpack to other complex types.
Template Parameters
T2target element type. It must be narrower than the vector's element type.
Parameters
v_signReturned vector is signed or not, regardless of the underlying type.

◆ push()

template<ElemBaseType T, unsigned Elems>
vector & aie::vector< T, Elems >::push ( value_type v)
inline

Adds a new element to the vector, moving existing elements one position up.

Shifts all elements in the vector up and writes the given value into the first position of the vector. The element in the last position of the vector is lost).

Parameters
vValue to be written into the first position of the vector

◆ set()

template<ElemBaseType T, unsigned Elems>
void aie::vector< T, Elems >::set ( value_type v,
unsigned idx )
inline

Updates the value of the element on the given index.

Parameters
vValue to write.
idxIndex of the element whose value is updated.

◆ size()

template<ElemBaseType T, unsigned Elems>
static constexpr unsigned aie::vector< T, Elems >::size ( )
inlinestaticconstexpr

Returns the number of elements in the vector.

◆ split()

template<ElemBaseType T, unsigned Elems>
template<unsigned ElemsOut>
auto aie::vector< T, Elems >::split ( ) const -> auto
inline

Returns the contents of the current vector stored in a std::tuple of subvectors.

Template Parameters
ElemsOutSize of each subvector.

◆ store()

template<ElemBaseType T, unsigned Elems>
template<aie_dm_resource Resource = aie_dm_resource::none, typename T2>
requires (std::is_same_v<aie_dm_resource_remove_t<T2>, value_type>)
void aie::vector< T, Elems >::store ( T2 * ptr) const
inline

Writes the contents of the vector into the given memory address.

Address is assumed to meet the alignment requirements for vector stores (>= 32 bytes).

Parameters
ptrPointer to the location where the vector contents must be written in memory.

◆ store_unaligned()

template<ElemBaseType T, unsigned Elems>
template<aie_dm_resource Resource = aie_dm_resource::none, typename T2>
requires (std::is_same_v<aie_dm_resource_remove_t<T2>, value_type>)
void aie::vector< T, Elems >::store_unaligned ( T2 * ptr,
unsigned aligned_elems ) const
inline

Writes the contents of the vector into the given memory address.

Address is assumed to be aligned to the given amount of elements.

Parameters
ptrPointer to the location where the vector contents must be written in memory.
aligned_elemsNumber of elements ptr is aligned to.

◆ to_native()

template<ElemBaseType T, unsigned Elems>
native_type aie::vector< T, Elems >::to_native ( ) const
inline

Returns the value of the vector using its native type.

◆ unpack()

template<ElemBaseType T, unsigned Elems>
template<UnpackableFrom< T > T2>
auto aie::vector< T, Elems >::unpack ( ) const -> vector<T2, Elems>
inline

Returns a copy of the vector with elements represented in a wider type.

By default, unpacking a vector will produce a vector with twice the number of bits. For example, unpacking a vector of 8b elements will produce a vector of 16b elements.

Note
Only vectors with integer elements are allowed.
Complex vectors can only unpack to other complex types.
Template Parameters
T2target element type. It must be wider than the vector's element type.

◆ unpack_sign()

template<ElemBaseType T, unsigned Elems>
template<UnpackableFrom< T > T2>
auto aie::vector< T, Elems >::unpack_sign ( bool v_sign) const -> vector<T2, Elems>
inline

Returns a copy of the vector with elements represented in a wider type, with dynamic selection of whether vectors are signed or not.

By default, unpacking a vector will produce a vector with twice the number of bits. For example, unpacking a vector of 8b elements will produce a vector of 16b elements.

Note
Only vectors with integer elements are allowed.
Complex vectors can only unpack to other complex types.
Template Parameters
T2target element type. It must be wider than the vector's element type.
Parameters
v_signReturned vector is signed or not, regardless of the underlying type.

◆ upd_all()

template<ElemBaseType T, unsigned Elems>
template<typename... SubVectors>
vector & aie::vector< T, Elems >::upd_all ( SubVectors &&... subvectors)
inline

Updates the contents of the vector using the values in the given subvectors.

Subvectors must be of the same type and size.

Parameters
subvectorsList of subvectors.

Friends And Related Symbol Documentation

◆ vector

template<ElemBaseType T, unsigned Elems>
template<ElemBaseType T2, unsigned E2>
friend class vector
friend

◆ detail::vector_base

template<ElemBaseType T, unsigned Elems>
template<typename T2, unsigned E2>
friend class detail::vector_base
friend

◆ aie::vector_elem_const_ref

class aie::vector_elem_const_ref
template<ElemBaseType T, unsigned N>
class aie::vector_elem_const_ref< T, N >

Reference to immutable vector element.

Template Parameters
TType of the elements contained in the referenced vector. It must meet aie::ElemBaseType.
ElemsNumber of elements in the referenced vector.
See also
aie::vector_elem_ref

Public Types

using parent_type = vector_type
 
using value_type = T
 
using vector_type = vector<T, N>
 

Public Member Functions

constexpr vector_elem_const_ref (const vector_elem_ref< T, N > &ref)
 Converts a mutable reference into an immutable reference.
 
value_type get () const
 Access the element value.
 
 operator value_type () const
 Cast operator.
 
template<typename T2>
constexpr bool operator!= (T2 v) const
 Compares element value with another.
 
template<typename T2>
constexpr bool operator< (T2 v) const
 Compares element value with another.
 
template<typename T2>
constexpr bool operator<= (T v) const
 Compares element value with another.
 
template<typename T2>
constexpr bool operator== (T2 v) const
 Compares element value with another.
 
template<typename T2>
constexpr bool operator> (T2 v) const
 Compares element value with another.
 
template<typename T2>
constexpr bool operator>= (T2 v) const
 Compares element value with another.
 

Public Attributes

unsigned offset
 The position within a vector where the element is located.
 
const vector_typeparent
 The vector where the referenced element is located.
 

Member Typedef Documentation

◆ parent_type

template<ElemBaseType T, unsigned N>
using aie::vector_elem_const_ref< T, N >::parent_type = vector_type

◆ value_type

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

◆ vector_type

template<ElemBaseType T, unsigned N>
using aie::vector_elem_const_ref< T, N >::vector_type = vector<T, N>

Constructor & Destructor Documentation

◆ vector_elem_const_ref()

template<ElemBaseType T, unsigned N>
aie::vector_elem_const_ref< T, N >::vector_elem_const_ref ( const vector_elem_ref< T, N > & ref)
inlineconstexpr

Converts a mutable reference into an immutable reference.

Member Function Documentation

◆ get()

template<ElemBaseType T, unsigned N>
value_type aie::vector_elem_const_ref< T, N >::get ( ) const
inline

Access the element value.

◆ operator value_type()

template<ElemBaseType T, unsigned N>
aie::vector_elem_const_ref< T, N >::operator value_type ( ) const
inline

Cast operator.

Access the element value.

◆ operator!=()

template<ElemBaseType T, unsigned N>
template<typename T2>
bool aie::vector_elem_const_ref< T, N >::operator!= ( T2 v) const
inlineconstexpr

Compares element value with another.

◆ operator<()

template<ElemBaseType T, unsigned N>
template<typename T2>
bool aie::vector_elem_const_ref< T, N >::operator< ( T2 v) const
inlineconstexpr

Compares element value with another.

◆ operator<=()

template<ElemBaseType T, unsigned N>
template<typename T2>
bool aie::vector_elem_const_ref< T, N >::operator<= ( T v) const
inlineconstexpr

Compares element value with another.

◆ operator==()

template<ElemBaseType T, unsigned N>
template<typename T2>
bool aie::vector_elem_const_ref< T, N >::operator== ( T2 v) const
inlineconstexpr

Compares element value with another.

◆ operator>()

template<ElemBaseType T, unsigned N>
template<typename T2>
bool aie::vector_elem_const_ref< T, N >::operator> ( T2 v) const
inlineconstexpr

Compares element value with another.

◆ operator>=()

template<ElemBaseType T, unsigned N>
template<typename T2>
bool aie::vector_elem_const_ref< T, N >::operator>= ( T2 v) const
inlineconstexpr

Compares element value with another.

Member Data Documentation

◆ offset

template<ElemBaseType T, unsigned N>
unsigned aie::vector_elem_const_ref< T, N >::offset

The position within a vector where the element is located.

◆ parent

template<ElemBaseType T, unsigned N>
const vector_type& aie::vector_elem_const_ref< T, N >::parent

The vector where the referenced element is located.

◆ aie::vector_elem_ref

class aie::vector_elem_ref
template<ElemBaseType T, unsigned N>
class aie::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 aie::ElemBaseType.
ElemsNumber of elements in the referenced vector.
See also
aie::vector_elem_const_ref

Public Types

using parent_type = vector_type
 
using value_type = T
 
using vector_type = vector<T, N>
 

Public Member Functions

value_type get () const
 Access the element value.
 
 operator value_type () const
 Cast operator.
 
template<typename T2>
constexpr bool operator!= (T2 v) const
 Compares element value with another.
 
template<typename T2>
constexpr bool operator< (T2 v) const
 Compares element value with another.
 
template<typename T2>
constexpr bool operator<= (T v) const
 Compares element value with another.
 
vector_elem_refoperator= (const value_type &v)
 Assignment operator.
 
vector_elem_refoperator= (const vector_elem_const_ref< T, N > &v)
 Assignment operator.
 
vector_elem_refoperator= (const vector_elem_ref< T, N > &v)
 Assignment operator.
 
template<typename T2>
constexpr bool operator== (T2 v) const
 Compares element value with another.
 
template<typename T2>
constexpr bool operator> (T2 v) const
 Compares element value with another.
 
template<typename T2>
constexpr bool operator>= (T2 v) const
 Compares element value with another.
 

Public Attributes

unsigned offset
 
vector_typeparent
 

Member Typedef Documentation

◆ parent_type

template<ElemBaseType T, unsigned N>
using aie::vector_elem_ref< T, N >::parent_type = vector_type

◆ value_type

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

◆ vector_type

template<ElemBaseType T, unsigned N>
using aie::vector_elem_ref< T, N >::vector_type = vector<T, N>

Member Function Documentation

◆ get()

template<ElemBaseType T, unsigned N>
value_type aie::vector_elem_ref< T, N >::get ( ) const
inline

Access the element value.

◆ operator value_type()

template<ElemBaseType T, unsigned N>
aie::vector_elem_ref< T, N >::operator value_type ( ) const
inline

Cast operator.

Access the element value.

◆ operator!=()

template<ElemBaseType T, unsigned N>
template<typename T2>
bool aie::vector_elem_ref< T, N >::operator!= ( T2 v) const
inlineconstexpr

Compares element value with another.

◆ operator<()

template<ElemBaseType T, unsigned N>
template<typename T2>
bool aie::vector_elem_ref< T, N >::operator< ( T2 v) const
inlineconstexpr

Compares element value with another.

◆ operator<=()

template<ElemBaseType T, unsigned N>
template<typename T2>
bool aie::vector_elem_ref< T, N >::operator<= ( T v) const
inlineconstexpr

Compares element value with another.

◆ operator=() [1/3]

template<ElemBaseType T, unsigned N>
vector_elem_ref & aie::vector_elem_ref< T, N >::operator= ( const value_type & v)
inline

Assignment operator.

Overwrites the referenced value.

◆ operator=() [2/3]

template<ElemBaseType T, unsigned N>
vector_elem_ref & aie::vector_elem_ref< T, N >::operator= ( const vector_elem_const_ref< T, N > & v)
inline

Assignment operator.

Overwrites the referenced value.

◆ operator=() [3/3]

template<ElemBaseType T, unsigned N>
vector_elem_ref & aie::vector_elem_ref< T, N >::operator= ( const vector_elem_ref< T, N > & v)
inline

Assignment operator.

Overwrites the referenced value.

◆ operator==()

template<ElemBaseType T, unsigned N>
template<typename T2>
bool aie::vector_elem_ref< T, N >::operator== ( T2 v) const
inlineconstexpr

Compares element value with another.

◆ operator>()

template<ElemBaseType T, unsigned N>
template<typename T2>
bool aie::vector_elem_ref< T, N >::operator> ( T2 v) const
inlineconstexpr

Compares element value with another.

◆ operator>=()

template<ElemBaseType T, unsigned N>
template<typename T2>
bool aie::vector_elem_ref< T, N >::operator>= ( T2 v) const
inlineconstexpr

Compares element value with another.

Member Data Documentation

◆ offset

template<ElemBaseType T, unsigned N>
unsigned aie::vector_elem_ref< T, N >::offset

◆ parent

template<ElemBaseType T, unsigned N>
vector_type& aie::vector_elem_ref< T, N >::parent