AI Engine API User Guide (AIE) 2023.2
|
The two main types offered by the AIE API are vectors (aie::vector) and accumulators (aie::accum). More...
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.
Arch. | int4 | uint4 | int8 | uint8 | int16 | uint16 | int32 | uint32 | bfloat16 | float | cint16 | cint32 | cfloat |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 | 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 | 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
:
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.
Arch. | acc32 | acc40 | acc48 | acc56 | acc64 | acc72 | acc80 | accfloat | cacc32 | cacc40 | cacc48 | cacc56 | cacc64 | cacc72 | cacc80 | caccfloat | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 | 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 |
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:
Refer to Basic Type Initialization for examples of how to initialize accumulator objects.
Mask
Some comparison operations return masks. A mask is a collection of values that can be 0 or 1.
Refer to Basic Type Initialization for examples of how to initialize mask objects.
Modules | |
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::vector< T, Elems > |
Type for vector registers. More... | |
class | aie::vector_elem_const_ref< T, N > |
Constant reference to vector element. More... | |
class | aie::vector_elem_ref< T, N > |
Reference to vector element. More... | |
Typedefs | |
template<ElemBaseType T, unsigned Elems = native_vector_length_v<T>> | |
using | aie::sparse_vector = detail::sparse_vector< T, Elems > |
Type for sparse vector registers. | |
Class Documentation
◆ aie::accum
class aie::accum |
class aie::accum< MinAccumTag, Elems >
Type for vector accumulators.
- 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 meet AccumElemBaseType. See also: accumulator element types. Elems Number 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 ElemsIn, AccumElemBaseType Tag2> | |
accum & | insert (unsigned idx, const accum< Tag2, ElemsIn > &acc) |
Updates the contents of a region of the accumulator with a native subaccumulator. | |
template<unsigned ElemsIn> | |
accum & | insert (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 > | |
accum & | operator= (const vector< T, Elems > &v) |
Updates the contents of the accumulator using the values in the given vector. | |
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 > | |
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. | |
Friends | |
template<AccumElemBaseType Tag2, unsigned E2> | |
class | accum |
template<detail::AccumClass Class, unsigned MinBits, unsigned E2> | |
class | accum_base |
Member Typedef Documentation
◆ storage_t
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
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]
|
default |
Default constructor.
The value of the elements is undefined.
◆ accum() [2/5]
|
default |
Copy constructor.
◆ accum() [3/5]
requires (has_same_representation<Tag2>())
|
inline |
Copies another accumulator with the same underlying representation.
◆ accum() [4/5]
|
inline |
Construct from internal storage type.
- Parameters
-
data Data used to construct the accumulator from.
◆ accum() [5/5]
|
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
-
v Data used to construct the accumulator from. shift Upshift value.
Member Function Documentation
◆ bits()
|
inlinestaticconstexpr |
Returns the total size of the accumulator in bits.
◆ cast_to()
|
inline |
Reinterprets the current accumulator as an accumulator of the given type.
The number of elements is automatically computed by the function
- Template Parameters
-
DstTag Type the accumulator will be cast to
◆ extract()
|
inline |
Returns a subaccumulator with the contents of a region of the accumulator.
- Template Parameters
-
ElemsOut Size of the returned subaccumulator.
- Parameters
-
idx Index of the subaccumulator to be returned.
◆ from_vector()
|
inline |
Updates the contents of the accumulator using the values in the given vector after applying the requested upshift operation.
- Parameters
-
v Input vector. shift Number of bits to be upshifted.
◆ from_vector_sign()
|
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 or later architectures only.
- Parameters
-
v Input vector. v_sign Values are considered signed or not, regardless of the underlying type. shift Number of bits to be upshifted.
◆ grow()
|
inline |
Returns a copy of the current accumulator in a larger accumulator.
The value of the new elements is undefined.
- Template Parameters
-
ElemsOut Size of the output accumulator.
◆ grow_extract()
|
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
◆ insert() [1/2]
|
inline |
Updates the contents of a region of the accumulator with a native subaccumulator.
- Parameters
-
idx Index of the subaccumulator to be replaced. acc Native subaccumulator to be written into the region.
- Returns
- Reference to the updated accumulator.
◆ insert() [2/2]
|
inline |
Updates the contents of a region of the accumulator using the values in the given native subaccumulator.
- Parameters
-
idx Index of the subaccumulator to be replaced. acc Native subaccumulator to be written into the region.
- Returns
- Reference to the updated accumulator.
◆ is_complex()
|
inlinestaticconstexpr |
Returns true if the element class is a complex number.
◆ is_floating_point()
|
inlinestaticconstexpr |
Returns true if the element class is a floating point number.
◆ is_real()
|
inlinestaticconstexpr |
Returns true if the element class is a real number.
◆ operator storage_t()
|
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 >()
requires (detail::accum_class_for_type_v<T> == value_class() && is_floating_point() && size() <= 32)
|
inline |
Performs the conversion of a FP32/CFP32 accumulator to a vector of the same type.
◆ operator=()
|
inline |
Updates the contents of the accumulator using the values in the given vector.
No upshift is applied.
- Parameters
-
v Input vector.
◆ size()
|
inlinestaticconstexpr |
Returns the number of elements in the accumulator.
◆ to_native()
|
inline |
Returns the native type of the accumulator.
Only valid when the number of subaccumulators is 1.
◆ to_vector() [1/2]
|
inline |
Returns the values of the FP32 accumulator in a vector of the requested type.
◆ to_vector() [2/2]
|
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.
- Parameters
-
shift Number of bits that need to be downshifted.
◆ to_vector_sign()
|
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 or later architectures only.
- Parameters
-
v_sign Returned vector is signed or not, regardless of the underlying type. shift Number of bits that need to be downshifted.
◆ to_vector_zip()
|
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
-
shift Number of bits that need to be downshifted.
◆ upd_all()
requires (Elems == (E2 + (Es + ...)) && ((Elems / E2 == Elems / Es) && ...))
|
inline |
Updates the contents of the accumulator using the values in the given subaccumulators.
Subaccumulators must be of the same class and size.
- Parameters
-
subacc First sub-accumulator. subaccums Remaining sub-accumulators.
◆ value_class()
|
inlinestaticconstexpr |
Returns the class of the accumulator elements.
Friends And Related Symbol Documentation
◆ accum
|
friend |
◆ accum_base
|
friend |
◆ aie::mask
class aie::mask |
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
-
Elems Number 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. | |
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 i) const |
Returns the contents of a section of the mask into a smaller mask. | |
constexpr mask | operator& (const mask &a) const |
Returns the result of merging the current and the given masks using the AND operation. | |
constexpr mask & | operator&= (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 mask & | operator<<= (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 mask & | operator>>= (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 mask & | operator|= (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. | |
Friends | |
template<unsigned Elems2> | |
class | mask |
Constructor & Destructor Documentation
◆ mask() [1/2]
|
inlineexplicitconstexpr |
Creates a mask.
- Parameters
-
initial_set If true, the mask is initialized with 1s, otherise it is initialized with 0s.
◆ mask() [2/2]
|
inlineexplicitconstexpr |
Construct from unsigned (32b) words.
Each bit in the input words is used to initialize one of the elements in the mask.
- Parameters
-
w First word used to initialize the mask. words Rest of words used to initialize the mask.
Member Function Documentation
◆ clear()
|
inlineconstexpr |
Sets the value of the element in the given index to 0.
- Parameters
-
i Element index.
◆ clz()
|
inlineconstexpr |
Returns the count of consecutive elements, starting at the high part of the mask, whose value is 0.
◆ count()
|
inlineconstexpr |
Returns the count of elements whose value is 1.
◆ data()
|
inlineconstexpr |
- Deprecated:
- Use alternative functions to access the elements of a mask.
- See also
- to_uint32, to_uint64, get_submask
◆ empty()
|
inlineconstexpr |
Returns a bool that says whether the value of all the elements in the mask is 0.
◆ from_masks()
requires (Elems == (E + (Es + ...)) && ((E == Es) && ...))
|
inlinestaticconstexpr |
Construct from concatenating multiple smaller masks.
- Parameters
-
w First mask used to initialize least significant elements in the new mask. masks Other masks used to initialize the rest of the elements.
◆ from_uint32()
|
inlinestaticconstexpr |
Construct from unsigned (32b) words.
Each bit in the input words is used to initialize one of the elements in the mask.
- Parameters
-
w First word used to initialize the mask. words Rest of words used to initialize the mask.
◆ from_uint64()
|
inlinestaticconstexpr |
Construct from unsigned (64b) words.
Each bit in the input words is used to initialize one of the elements in the mask.
- Parameters
-
w First word used to initialize the mask. words Rest of words used to initialize the mask.
◆ full()
|
inlineconstexpr |
Returns a bool that says whether the value of all the elements in the mask is 1.
◆ get_submask()
|
inlineconstexpr |
Returns the contents of a section of the mask into a smaller mask.
- Template Parameters
-
ElemsOut Size of the returned mask
- Parameters
-
i Index of the section within th mask (in chunks of ElemsOut elements)
◆ operator&()
|
inlineconstexpr |
Returns the result of merging the current and the given masks using the AND operation.
- Parameters
-
a Mask to merge with.
◆ operator&=()
|
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
-
a Mask to merge with.
◆ operator<<()
|
inlineconstexpr |
Returns the result of a binary left shift of the mask.
- Parameters
-
shift Number of positions to shift the mask.
◆ operator<<=()
|
inlineconstexpr |
Returns the result of a binary left shift of the mask.
Returns a reference to the updated mask.
- Parameters
-
shift Number of positions to shift the mask.
◆ operator==()
|
inlineconstexpr |
Compares whether two masks are equal.
- Parameters
-
a Mask to compare against.
◆ operator>>()
|
inlineconstexpr |
Returns the result of a binary right shift of the mask.
- Parameters
-
shift Number of positions to shift the mask.
◆ operator>>=()
|
inlineconstexpr |
Returns the result of a binary right shift of the mask.
Returns a reference to the updated mask.
- Parameters
-
shift Number of positions to shift the mask.
◆ operator|()
|
inlineconstexpr |
Returns the result of merging the current and the given masks using the OR operation.
- Parameters
-
a Mask to merge with.
◆ operator|=()
|
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
-
a Mask to merge with.
◆ operator~()
Returns a mask that contains the negation of the values of all the elements in the mask (0->1, 1->0).
◆ set()
|
inlineconstexpr |
Sets the value of the element in the given index to 1.
- Parameters
-
i Element index.
◆ size()
|
inlinestaticconstexpr |
Returns the number of elements in the mask.
◆ test()
|
inlineconstexpr |
Returns the value of the element in the given index.
- Parameters
-
i Element index.
◆ to_uint32() [1/2]
requires (Elems2 <= 32)
|
inlineconstexpr |
Returns the contents of the mask in a 32b unsigned integer.
◆ to_uint32() [2/2]
|
inlineconstexpr |
Returns the contents of a section of the mask in a 32b unsigned integer.
- Parameters
-
i Index of the section within the mask (in chunks of 32 elements)
◆ to_uint64() [1/2]
requires (Elems2 == 64)
|
inlineconstexpr |
Returns the contents of the mask in a 64b unsigned integer.
◆ to_uint64() [2/2]
|
inlineconstexpr |
Returns the contents of a section of the mask in a 64b unsigned integer.
- Parameters
-
i Index of the section within th mask (in chunks of 64 elements)
Friends And Related Symbol Documentation
◆ mask
◆ aie::vector
class aie::vector |
class aie::vector< T, Elems >
Type for vector registers.
- Template Parameters
-
T Type of the elements contained in the vector. It must meet ElemBaseType. Elems Number 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> | |
vector & | insert (unsigned idx, const vector< T, ElemsIn > &v) |
Updates the contents of a region of the vector. | |
template<unsigned ElemsIn> | |
vector & | insert (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<typename T2 = typename detail::packed_type<T>::type> | |
auto | pack () const -> vector< T2, Elems > |
Returns a copy of the vector's elements represented in half their number of bits. | |
template<typename T2 = typename detail::packed_type<T>::type> | |
auto | pack_sign (bool v_sign) const -> vector< T2, Elems > |
Returns a copy of the vector's elements represented in half their number of bits. | |
vector & | push (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<typename T2 = typename detail::unpacked_type<T>::type> | |
auto | unpack () const -> vector< T2, Elems > |
Returns a copy of the vector's elements represented in twice their number of bits. | |
template<typename T2 = typename detail::unpacked_type<T>::type> | |
auto | unpack_sign (bool v_sign) const -> vector< T2, Elems > |
FIXME: AIE1 vs AIE2. | |
template<typename... SubVectors> | |
vector & | upd_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 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. | |
Friends | |
template<ElemBaseType T2, unsigned E2> | |
class | vector |
template<typename T2 , unsigned E2> | |
class | detail::vector_base |
Member Typedef Documentation
◆ native_type
using aie::vector< T, Elems >::native_type = typename base_type::native_type |
Equivalent intrinsic type for the same element type and size.
◆ storage_t
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
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]
|
inline |
Default constructor.
The value of the elements is undefined.
◆ vector() [2/4]
|
inline |
Construct a vector from internal native types.
- Parameters
-
v Data used to construct the vector from.
◆ vector() [3/4]
|
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
-
v Data used to construct the vector from
◆ vector() [4/4]
|
inlineexplicit |
Construct from a list of values.
- Parameters
-
v First value in the list values Rest of values in the list
Member Function Documentation
◆ bits()
|
inlinestaticconstexpr |
Returns the total size of the vector in bits.
◆ cast_to()
|
inline |
Reinterprets the current vector as a vector of the given type.
The number of elements is automatically computed by the function
- Template Parameters
-
DstT Type the vector will be cast to
◆ elem_const_ref()
|
inlineconstexpr |
Returns a constant reference object to the element on the given index.
- Parameters
-
idx Index of the element.
◆ elem_ref() [1/2]
|
inlineconstexpr |
Returns a reference object to the element on the given index.
- Parameters
-
idx Index of the element.
◆ elem_ref() [2/2]
|
inlineconstexpr |
Returns a constant reference object to the element on the given index.
- Parameters
-
idx Index of the element.
◆ extract()
|
inline |
Returns a subvector with the contents of a region of the vector.
- Template Parameters
-
ElemsOut Size of the returned subvector.
- Parameters
-
idx Index of the subvector to be returned.
◆ get()
|
inline |
Returns the value of the element on the given index.
- Parameters
-
idx Index of the element.
◆ grow()
|
inlineconstexpr |
Returns a copy of the current vector in a larger vector.
The value of the new elements is undefined.
- Template Parameters
-
ElemsOut Size of the output vector.
- Parameters
-
idx Location of the subvector within the output vector
◆ grow_extract()
|
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.
◆ grow_replicate()
|
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
-
ElemsOut Size of the output vector.
◆ insert() [1/2]
|
inline |
Updates the contents of a region of the vector.
The updated region will contain the values in the given subvector.
- Parameters
-
idx Index of the subvector to be replaced. v Subvector to be written into the region.
- Returns
- a reference to the updated vector.
◆ insert() [2/2]
|
inline |
Updates the contents of a region of the vector using.
The updated region will contain the values in the given native subvector.
- Parameters
-
idx Index of the subvector to be replaced. v Native subvector to be written into the region.
- Returns
- a reference to the updated vector.
◆ is_complex()
|
inlinestaticconstexpr |
Returns true if the element type is a complex number.
◆ is_floating_point()
|
inlinestaticconstexpr |
Returns true if the element type is floating-point.
◆ is_integral()
|
inlinestaticconstexpr |
Returns true if the element type is an integer.
◆ is_real()
|
inlinestaticconstexpr |
Returns true if the element type is a real number.
◆ is_signed()
|
inlinestaticconstexpr |
Returns true if the element type is signed.
◆ load()
requires (std::is_same_v<aie_dm_resource_remove_t<T2>, value_type>)
|
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
-
ptr Pointer to the location of the values in memory.
◆ load_unaligned()
requires (std::is_same_v<aie_dm_resource_remove_t<T2>, value_type>)
|
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
-
ptr Pointer to the location of the values in memory. aligned_elems Number of elements ptr is aligned to.
◆ operator native_type()
|
inline |
Operator for conversion to the native type.
◆ operator[]() [1/2]
|
inlineconstexpr |
Returns a reference object to the element on the given index.
- Parameters
-
idx Index of the element.
◆ operator[]() [2/2]
|
inlineconstexpr |
Returns a constant reference object to the element on the given index.
- Parameters
-
idx Index of the element.
◆ pack()
|
inline |
Returns a copy of the vector's elements represented in half their number of bits.
For example, unpacking a vector of 16b elements will produce a vector of 8b elements.
◆ pack_sign()
|
inline |
Returns a copy of the vector's elements represented in half their number of bits.
It can specify the sign of the returned type.
- Note
- Not currently functional on AIE1 architecture
- Parameters
-
v_sign Returned vector is signed or not, regardless of the underlying type.
◆ push()
|
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
-
v Value to be written into the first position of the vector
◆ set()
|
inline |
Updates the value of the element on the given index.
- Parameters
-
v Value to write. idx Index of the element whose value is updated.
◆ size()
|
inlinestaticconstexpr |
Returns the number of elements in the vector.
◆ split()
|
inline |
Returns the contents of the current vector stored in a std::tuple of subvectors.
- Template Parameters
-
ElemsOut Size of each subvector.
◆ store()
requires (std::is_same_v<aie_dm_resource_remove_t<T2>, value_type>)
|
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
-
ptr Pointer to the location where the vector contents must be written in memory.
◆ store_unaligned()
requires (std::is_same_v<aie_dm_resource_remove_t<T2>, value_type>)
|
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
-
ptr Pointer to the location where the vector contents must be written in memory. aligned_elems Number of elements ptr is aligned to.
◆ to_native()
|
inline |
Returns the value of the vector using its native type.
◆ unpack()
|
inline |
Returns a copy of the vector's elements represented in twice their number of bits.
For example, unpacking a vector of 8b elements will produce a vector of 16b elements.
◆ unpack_sign()
|
inline |
FIXME: AIE1 vs AIE2.
Returns a copy of the vector's elements represented in twice their number of bits. It can specify the sign of the returned type.
- Parameters
-
v_sign Returned vector is signed or not, regardless of the underlying type.
◆ upd_all()
|
inline |
Updates the contents of the vector using the values in the given subvectors.
Subvectors must be of the same type and size.
- Parameters
-
subvectors List of subvectors.
Friends And Related Symbol Documentation
◆ vector
|
friend |
◆ detail::vector_base
|
friend |
◆ aie::vector_elem_const_ref
class aie::vector_elem_const_ref |
class aie::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
-
T Type of the elements contained in the referenced vector. It must meet ElemBaseType. Elems Number of elements in the referenced vector.
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) |
value_type | get () const |
operator value_type () const | |
template<typename T2 > | |
constexpr bool | operator!= (T2 v) const |
template<typename T2 > | |
constexpr bool | operator< (T2 v) const |
template<typename T2 > | |
constexpr bool | operator<= (T v) const |
template<typename T2 > | |
constexpr bool | operator== (T2 v) const |
template<typename T2 > | |
constexpr bool | operator> (T2 v) const |
template<typename T2 > | |
constexpr bool | operator>= (T2 v) const |
Public Attributes | |
unsigned | offset |
const vector_type & | parent |
Member Typedef Documentation
◆ parent_type
using aie::vector_elem_const_ref< T, N >::parent_type = vector_type |
◆ value_type
using aie::vector_elem_const_ref< T, N >::value_type = T |
◆ vector_type
using aie::vector_elem_const_ref< T, N >::vector_type = vector<T, N> |
Constructor & Destructor Documentation
◆ vector_elem_const_ref()
|
inlineconstexpr |
Member Function Documentation
◆ get()
|
inline |
◆ operator value_type()
|
inline |
◆ operator!=()
|
inlineconstexpr |
◆ operator<()
|
inlineconstexpr |
◆ operator<=()
|
inlineconstexpr |
◆ operator==()
|
inlineconstexpr |
◆ operator>()
|
inlineconstexpr |
◆ operator>=()
|
inlineconstexpr |
Member Data Documentation
◆ offset
unsigned aie::vector_elem_const_ref< T, N >::offset |
◆ parent
const vector_type& aie::vector_elem_const_ref< T, N >::parent |
◆ aie::vector_elem_ref
class aie::vector_elem_ref |
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
-
T Type of the elements contained in the referenced vector. It must meet ElemBaseType. Elems Number of elements in the referenced vector.
Public Types | |
using | parent_type = vector_type |
using | value_type = T |
using | vector_type = vector< T, N > |
Public Member Functions | |
value_type | get () const |
operator value_type () const | |
template<typename T2 > | |
constexpr bool | operator!= (T2 v) const |
template<typename T2 > | |
constexpr bool | operator< (T2 v) const |
template<typename T2 > | |
constexpr bool | operator<= (T v) const |
vector_elem_ref & | operator= (const value_type &v) |
vector_elem_ref & | operator= (const vector_elem_const_ref< T, N > &v) |
vector_elem_ref & | operator= (const vector_elem_ref< T, N > &v) |
template<typename T2 > | |
constexpr bool | operator== (T2 v) const |
template<typename T2 > | |
constexpr bool | operator> (T2 v) const |
template<typename T2 > | |
constexpr bool | operator>= (T2 v) const |
Public Attributes | |
unsigned | offset |
vector_type & | parent |
Member Typedef Documentation
◆ parent_type
using aie::vector_elem_ref< T, N >::parent_type = vector_type |
◆ value_type
using aie::vector_elem_ref< T, N >::value_type = T |
◆ vector_type
using aie::vector_elem_ref< T, N >::vector_type = vector<T, N> |
Member Function Documentation
◆ get()
|
inline |
◆ operator value_type()
|
inline |
◆ operator!=()
|
inlineconstexpr |
◆ operator<()
|
inlineconstexpr |
◆ operator<=()
|
inlineconstexpr |
◆ operator=() [1/3]
|
inline |
◆ operator=() [2/3]
|
inline |
◆ operator=() [3/3]
|
inline |
◆ operator==()
|
inlineconstexpr |
◆ operator>()
|
inlineconstexpr |
◆ operator>=()
|
inlineconstexpr |
Member Data Documentation
◆ offset
unsigned aie::vector_elem_ref< T, N >::offset |
◆ parent
vector_type& aie::vector_elem_ref< T, N >::parent |
Typedef Documentation
◆ sparse_vector
using aie::sparse_vector = typedef detail::sparse_vector<T, Elems> |
Type for sparse vector registers.
The documentation of this class and its members can be found at detail::sparse_vector.
- Template Parameters
-
T Type of the elements contained in the sparse vector. It must meet ElemBaseType. Elems Number of elements in the sparse vector.