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...
The two main types offered by the AIE API are vectors (aie::vector) and accumulators (aie::accum).
A vector represents a collection of elements of the same type which is transparently mapped to the corresponding vector registers supported on each architecture. Vectors are parametrized by the element type and the number of elements, and any combination that defines a 128b/256b/512b/1024b vector is supported.
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.
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.
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 aie::accum |
Type for vector accumulators.
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 |
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.
using aie::accum< MinAccumTag, Elems >::value_type = typename base_type::value_type |
Type of the elements in the accumulator.
|
default |
Default constructor.
The value of the elements is undefined.
|
default |
Copy constructor.
|
inline |
Copies another accumulator with the same underlying representation.
|
inline |
Construct from internal storage type.
data | Data used to construct the accumulator from. |
|
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.
v | Data used to construct the accumulator from. |
shift | Upshift value. |
|
inlinestaticconstexpr |
Returns the total size of the accumulator in bits.
|
inline |
Reinterprets the current accumulator as an accumulator of the given type.
The number of elements is automatically computed by the function
DstTag | Type the accumulator will be cast to |
|
inline |
Returns a subaccumulator with the contents of a region of the accumulator.
ElemsOut | Size of the returned subaccumulator. |
idx | Index of the subaccumulator to be returned. |
|
inline |
Updates the contents of the accumulator using the values in the given vector after applying the requested upshift operation.
v | Input vector. |
shift | Number of bits to be upshifted. |
|
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.
v | Input vector. |
v_sign | Values are considered signed or not, regardless of the underlying type. |
shift | Number of bits to be upshifted. |
|
inline |
Returns a copy of the current accumulator in a larger accumulator.
The value of the new elements is undefined.
ElemsOut | Size of the output accumulator. |
|
inline |
Returns a copy of the accumulator with a new size.
extract(idx)
operation when the new size is smaller.grow()
operation when the new size is bigger.
|
inline |
Updates the contents of a region of the accumulator with a native subaccumulator.
idx | Index of the subaccumulator to be replaced. |
acc | Native subaccumulator to be written into the region. |
|
inline |
Updates the contents of a region of the accumulator using the values in the given native subaccumulator.
idx | Index of the subaccumulator to be replaced. |
acc | Native subaccumulator to be written into the region. |
|
inlinestaticconstexpr |
Returns true if the element class is a complex number.
|
inlinestaticconstexpr |
Returns true if the element class is a floating point number.
|
inlinestaticconstexpr |
Returns true if the element class is a real number.
|
inline |
Operator for conversion to the internal underlying type.
If the number of internal subaccumulators is 1, this type matches the native type.
|
inline |
Performs the conversion of a FP32/CFP32 accumulator to a vector of the same type.
|
inline |
Updates the contents of the accumulator using the values in the given vector.
No upshift is applied.
v | Input vector. |
|
inlinestaticconstexpr |
Returns the number of elements in the accumulator.
|
inline |
Returns the native type of the accumulator.
Only valid when the number of subaccumulators is 1.
|
inline |
Returns the values of the FP32 accumulator in a vector of the requested type.
|
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.
shift | Number of bits that need to be downshifted. |
|
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.
v_sign | Returned vector is signed or not, regardless of the underlying type. |
shift | Number of bits that need to be downshifted. |
|
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.
shift | Number of bits that need to be downshifted. |
|
inline |
Updates the contents of the accumulator using the values in the given subaccumulators.
Subaccumulators must be of the same class and size.
subacc | First sub-accumulator. |
subaccums | Remaining sub-accumulators. |
|
inlinestaticconstexpr |
Returns the class of the accumulator elements.
|
friend |
|
friend |
class aie::mask |
Type for vector element masks.
This type is returned by logical operations and used as input in selection operations.
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 |
|
inlineexplicitconstexpr |
Creates a mask.
initial_set | If true, the mask is initialized with 1s, otherise it is initialized with 0s. |
|
inlineexplicitconstexpr |
Construct from unsigned (32b) words.
Each bit in the input words is used to initialize one of the elements in the mask.
w | First word used to initialize the mask. |
words | Rest of words used to initialize the mask. |
|
inlineconstexpr |
Sets the value of the element in the given index to 0.
i | Element index. |
|
inlineconstexpr |
Returns the count of consecutive elements, starting at the high part of the mask, whose value is 0.
|
inlineconstexpr |
Returns the count of elements whose value is 1.
|
inlineconstexpr |
|
inlineconstexpr |
Returns a bool that says whether the value of all the elements in the mask is 0.
|
inlinestaticconstexpr |
Construct from concatenating multiple smaller masks.
w | First mask used to initialize least significant elements in the new mask. |
masks | Other masks used to initialize the rest of the elements. |
|
inlinestaticconstexpr |
Construct from unsigned (32b) words.
Each bit in the input words is used to initialize one of the elements in the mask.
w | First word used to initialize the mask. |
words | Rest of words used to initialize the mask. |
|
inlinestaticconstexpr |
Construct from unsigned (64b) words.
Each bit in the input words is used to initialize one of the elements in the mask.
w | First word used to initialize the mask. |
words | Rest of words used to initialize the mask. |
|
inlineconstexpr |
Returns a bool that says whether the value of all the elements in the mask is 1.
|
inlineconstexpr |
Returns the contents of a section of the mask into a smaller mask.
ElemsOut | Size of the returned mask |
i | Index of the section within th mask (in chunks of ElemsOut elements) |
|
inlineconstexpr |
Returns the result of merging the current and the given masks using the AND operation.
a | Mask to merge with. |
|
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.
a | Mask to merge with. |
|
inlineconstexpr |
Returns the result of a binary left shift of the mask.
shift | Number of positions to shift the mask. |
|
inlineconstexpr |
Returns the result of a binary left shift of the mask.
Returns a reference to the updated mask.
shift | Number of positions to shift the mask. |
|
inlineconstexpr |
Compares whether two masks are equal.
a | Mask to compare against. |
|
inlineconstexpr |
Returns the result of a binary right shift of the mask.
shift | Number of positions to shift the mask. |
|
inlineconstexpr |
Returns the result of a binary right shift of the mask.
Returns a reference to the updated mask.
shift | Number of positions to shift the mask. |
|
inlineconstexpr |
Returns the result of merging the current and the given masks using the OR operation.
a | Mask to merge with. |
|
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.
a | Mask to merge with. |
Returns a mask that contains the negation of the values of all the elements in the mask (0->1, 1->0).
|
inlineconstexpr |
Sets the value of the element in the given index to 1.
i | Element index. |
|
inlinestaticconstexpr |
Returns the number of elements in the mask.
|
inlineconstexpr |
Returns the value of the element in the given index.
i | Element index. |
|
inlineconstexpr |
Returns the contents of the mask in a 32b unsigned integer.
|
inlineconstexpr |
Returns the contents of a section of the mask in a 32b unsigned integer.
i | Index of the section within the mask (in chunks of 32 elements) |
|
inlineconstexpr |
Returns the contents of the mask in a 64b unsigned integer.
|
inlineconstexpr |
Returns the contents of a section of the mask in a 64b unsigned integer.
i | Index of the section within th mask (in chunks of 64 elements) |
class aie::vector |
Type for vector registers.
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 |
using aie::vector< T, Elems >::native_type = typename base_type::native_type |
Equivalent intrinsic type for the same element type and size.
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.
using aie::vector< T, Elems >::value_type = typename base_type::value_type |
Type of the elements in the vector.
|
inline |
Default constructor.
The value of the elements is undefined.
|
inline |
Construct a vector from internal native types.
v | Data used to construct the vector from. |
|
inline |
Construct from internal types.
This is a special case for 1024b internal vector types, which need to be broken into two 512b vectors
v | Data used to construct the vector from |
|
inlineexplicit |
Construct from a list of values.
v | First value in the list |
values | Rest of values in the list |
|
inlinestaticconstexpr |
Returns the total size of the vector in bits.
|
inline |
Reinterprets the current vector as a vector of the given type.
The number of elements is automatically computed by the function
DstT | Type the vector will be cast to |
|
inlineconstexpr |
Returns a constant reference object to the element on the given index.
idx | Index of the element. |
|
inlineconstexpr |
Returns a reference object to the element on the given index.
idx | Index of the element. |
|
inlineconstexpr |
Returns a constant reference object to the element on the given index.
idx | Index of the element. |
|
inline |
Returns a subvector with the contents of a region of the vector.
ElemsOut | Size of the returned subvector. |
idx | Index of the subvector to be returned. |
|
inline |
Returns the value of the element on the given index.
idx | Index of the element. |
|
inlineconstexpr |
Returns a copy of the current vector in a larger vector.
The value of the new elements is undefined.
ElemsOut | Size of the output vector. |
idx | Location of the subvector within the output vector |
|
inline |
Returns a copy of the current vector in a new size.
extract(idx)
operation when the new size is smaller.grow(idx)
operation when the new size is bigger.
|
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
ElemsOut | Size of the output vector. |
|
inline |
Updates the contents of a region of the vector.
The updated region will contain the values in the given subvector.
idx | Index of the subvector to be replaced. |
v | Subvector to be written into the region. |
|
inline |
Updates the contents of a region of the vector using.
The updated region will contain the values in the given native subvector.
idx | Index of the subvector to be replaced. |
v | Native subvector to be written into the region. |
|
inlinestaticconstexpr |
Returns true if the element type is a complex number.
|
inlinestaticconstexpr |
Returns true if the element type is floating-point.
|
inlinestaticconstexpr |
Returns true if the element type is an integer.
|
inlinestaticconstexpr |
Returns true if the element type is a real number.
|
inlinestaticconstexpr |
Returns true if the element type is signed.
|
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).
ptr | Pointer to the location of the values in memory. |
|
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.
ptr | Pointer to the location of the values in memory. |
aligned_elems | Number of elements ptr is aligned to. |
|
inline |
Operator for conversion to the native type.
|
inlineconstexpr |
Returns a reference object to the element on the given index.
idx | Index of the element. |
|
inlineconstexpr |
Returns a constant reference object to the element on the given index.
idx | Index of the element. |
|
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.
|
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.
v_sign | Returned vector is signed or not, regardless of the underlying type. |
|
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).
v | Value to be written into the first position of the vector |
|
inline |
Updates the value of the element on the given index.
v | Value to write. |
idx | Index of the element whose value is updated. |
|
inlinestaticconstexpr |
Returns the number of elements in the vector.
|
inline |
Returns the contents of the current vector stored in a std::tuple of subvectors.
ElemsOut | Size of each subvector. |
|
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).
ptr | Pointer to the location where the vector contents must be written in memory. |
|
inline |
Writes the contents of the vector into the given memory address.
Address is assumed to be aligned to the given amount of elements.
ptr | Pointer to the location where the vector contents must be written in memory. |
aligned_elems | Number of elements ptr is aligned to. |
|
inline |
Returns the value of the vector using its native type.
|
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.
|
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.
v_sign | Returned vector is signed or not, regardless of the underlying type. |
|
inline |
Updates the contents of the vector using the values in the given subvectors.
Subvectors must be of the same type and size.
subvectors | List of subvectors. |
|
friend |
|
friend |
class aie::vector_elem_const_ref |
Constant reference to vector element.
This is similar to aie::vector_elem_ref, but the element cannot be modified.
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 |
using aie::vector_elem_const_ref< T, N >::parent_type = vector_type |
using aie::vector_elem_const_ref< T, N >::value_type = T |
using aie::vector_elem_const_ref< T, N >::vector_type = vector<T, N> |
|
inlineconstexpr |
|
inline |
|
inline |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
unsigned aie::vector_elem_const_ref< T, N >::offset |
const vector_type& aie::vector_elem_const_ref< T, N >::parent |
class aie::vector_elem_ref |
Reference to vector element.
This type is returned by element access functions and represents a proxy to the actual element, which allows for optimizations in the API such as accessing the element from its vector without extracting it. This is common in element / vector operations. Otherwise, the element value is extracted when assigned to a variable of type T.
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 |
using aie::vector_elem_ref< T, N >::parent_type = vector_type |
using aie::vector_elem_ref< T, N >::value_type = T |
using aie::vector_elem_ref< T, N >::vector_type = vector<T, N> |
|
inline |
|
inline |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
|
inline |
|
inline |
|
inline |
|
inlineconstexpr |
|
inlineconstexpr |
|
inlineconstexpr |
unsigned aie::vector_elem_ref< T, N >::offset |
vector_type& aie::vector_elem_ref< T, N >::parent |
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.
T | Type of the elements contained in the sparse vector. It must meet ElemBaseType. |
Elems | Number of elements in the sparse vector. |