AI Engine API User Guide (AIE) 2022.2
|
AIE API provides a set of functions that implement arithmetic operations on vector types. Operands may be vectors, values or vector element references and the supported operand combinations are:
The following code snippet shows an example that adds two input arrays into an output array using vectors. For simplicity count must be divisible by 8.
Operations that include a multiplication return an accumulator. The API defines a default accumulation for each combination of types, but users may specify a larger number of accumulation bits by explicitly passing an accumulator tag.
Functions | |
template<Elem E> | |
constexpr auto | aie::abs (const E &a) -> operand_base_type_t< E > |
More... | |
template<Vector Vec> | |
constexpr auto | aie::abs (const Vec &v) -> aie_dm_resource_remove_t< Vec > |
More... | |
template<typename TR = int32, ComplexVector Vec> | |
constexpr auto | aie::abs_square (const Vec &v, int shift=0) |
More... | |
template<unsigned Elems> | |
constexpr vector< float, Elems > | aie::abs_square (const vector< cfloat, Elems > &v) |
More... | |
template<Accum Acc, Vector Vec> | |
Acc | aie::add (const Acc &acc, const Vec &v) |
More... | |
template<Accum Acc, Elem E> | |
Acc | aie::add (const Acc &acc, E a) |
More... | |
template<Vector Vec, Elem E> | |
auto | aie::add (const Vec &v, E a) -> aie_dm_resource_remove_t< Vec > |
More... | |
template<Vector Vec1, Vector Vec2> | |
auto | aie::add (const Vec1 &v1, const Vec2 &v2) -> aie_dm_resource_remove_t< Vec1 > |
More... | |
template<Elem E, Vector Vec> | |
auto | aie::add (E a, const Vec &v) -> aie_dm_resource_remove_t< Vec > |
More... | |
template<Elem E, Vector Vec> | |
auto | aie::bit_and (E a, const Vec &v) -> aie_dm_resource_remove_t< Vec > |
More... | |
template<Elem E, Vector Vec> | |
auto | aie::bit_or (E a, const Vec &v) -> aie_dm_resource_remove_t< Vec > |
More... | |
template<Elem E, Vector Vec> | |
auto | aie::bit_xor (E a, const Vec &v) -> aie_dm_resource_remove_t< Vec > |
More... | |
template<ComplexElem E> | |
constexpr auto | aie::conj (const E &a) -> operand_base_type_t< E > |
More... | |
template<ComplexVector Vec> | |
auto | aie::conj (const Vec &v) -> aie_dm_resource_remove_t< Vec > |
More... | |
template<AccumOrOp Acc, VectorOrOp Vec, ElemOrOp E> | |
constexpr auto | aie::mac (const Acc &acc, const Vec &v, E a) -> operand_base_type_t< Acc > |
More... | |
template<AccumOrOp Acc, VectorOrOp Vec1, VectorOrOp Vec2> | |
constexpr auto | aie::mac (const Acc &acc, const Vec1 &v1, const Vec2 &v2) -> operand_base_type_t< Acc > |
More... | |
template<AccumOrOp Acc, ElemOrOp E, VectorOrOp Vec> | |
constexpr auto | aie::mac (const Acc &acc, E a, const Vec &v) -> operand_base_type_t< Acc > |
More... | |
template<AccumOrOp Acc, Vector Vec> | |
constexpr auto | aie::mac_square (const Acc &acc, const Vec &v) |
More... | |
template<Accum Acc, VectorOrOp Vec, ElemOrOp E> | |
constexpr auto | aie::msc (const Acc &acc, const Vec &v, E a) -> aie_dm_resource_remove_t< Acc > |
More... | |
template<Accum Acc, VectorOrOp Vec1, VectorOrOp Vec2> | |
constexpr auto | aie::msc (const Acc &acc, const Vec1 &v1, const Vec2 &v2) -> aie_dm_resource_remove_t< Acc > |
More... | |
template<Accum Acc, ElemOrOp E, VectorOrOp Vec> | |
constexpr auto | aie::msc (const Acc &acc, E a, const Vec &v) -> aie_dm_resource_remove_t< Acc > |
More... | |
template<Accum Acc, Vector Vec> | |
constexpr auto | aie::msc_square (const Acc &acc, const Vec &v) |
More... | |
template<VectorOrOp Vec, ElemOrOp E> | |
constexpr auto | aie::mul (const Vec &v, E a) |
More... | |
template<AccumElemBaseType AccumTag, VectorOrOp Vec, ElemOrOp E> | |
constexpr auto | aie::mul (const Vec &v, E a) -> accum< AccumTag, Vec::size()> |
More... | |
template<VectorOrOp Vec1, VectorOrOp Vec2> | |
constexpr auto | aie::mul (const Vec1 &v1, const Vec2 &v2) |
More... | |
template<AccumElemBaseType AccumTag, VectorOrOp Vec1, VectorOrOp Vec2> | |
constexpr auto | aie::mul (const Vec1 &v1, const Vec2 &v2) -> accum< AccumTag, Vec1::size()> |
More... | |
template<ElemOrOp E, VectorOrOp Vec> | |
constexpr auto | aie::mul (E a, const Vec &v) |
More... | |
template<AccumElemBaseType AccumTag, ElemOrOp E, VectorOrOp Vec> | |
constexpr auto | aie::mul (E a, const Vec &v) -> accum< AccumTag, Vec::size()> |
More... | |
template<Vector Vec> | |
constexpr auto | aie::mul_square (const Vec &v) |
More... | |
template<AccumElemBaseType AccumTag, Vector Vec> | |
constexpr auto | aie::mul_square (const Vec &v) -> accum< AccumTag, Vec::size()> |
More... | |
template<Elem E> | |
constexpr auto | aie::neg (const E &a) -> operand_base_type_t< E > |
More... | |
template<Vector Vec> | |
constexpr auto | aie::neg (const Vec &v) -> aie_dm_resource_remove_t< Vec > |
More... | |
template<VectorOrOp Vec, ElemOrOp E> | |
constexpr auto | aie::negmul (const Vec &v, E a) |
More... | |
template<AccumElemBaseType AccumTag, VectorOrOp Vec, ElemOrOp E> | |
constexpr auto | aie::negmul (const Vec &v, E a) -> accum< AccumTag, Vec::size()> |
More... | |
template<VectorOrOp Vec1, VectorOrOp Vec2> | |
constexpr auto | aie::negmul (const Vec1 &v1, const Vec2 &v2) |
More... | |
template<AccumElemBaseType AccumTag, VectorOrOp Vec1, VectorOrOp Vec2> | |
constexpr auto | aie::negmul (const Vec1 &v1, const Vec2 &v2) -> accum< AccumTag, Vec1::size()> |
More... | |
template<ElemOrOp E, VectorOrOp Vec> | |
constexpr auto | aie::negmul (E a, const Vec &v) |
More... | |
template<AccumElemBaseType AccumTag, ElemOrOp E, VectorOrOp Vec> | |
constexpr auto | aie::negmul (E a, const Vec &v) -> accum< AccumTag, Vec::size()> |
More... | |
template<Vector Vec, Vector... Others> | |
auto | aie::reduce_add_v (const Vec &v, const Others &... others) -> aie_dm_resource_remove_t< Vec > |
More... | |
template<Accum Acc, Vector Vec> | |
constexpr auto | aie::sub (const Acc &acc, const Vec &v) -> aie_dm_resource_remove_t< Acc > |
More... | |
template<Accum Acc, Elem E> | |
auto | aie::sub (const Acc &acc, E a) -> aie_dm_resource_remove_t< Acc > |
More... | |
template<Vector Vec, Elem E> | |
auto | aie::sub (const Vec &v, E a) -> aie_dm_resource_remove_t< Vec > |
More... | |
template<Vector Vec1, Vector Vec2> | |
auto | aie::sub (const Vec1 &v1, const Vec2 &v2) -> aie_dm_resource_remove_t< Vec1 > |
More... | |
template<Elem E, Vector Vec> | |
auto | aie::sub (E a, const Vec &v) -> aie_dm_resource_remove_t< Vec > |
More... | |
|
constexpr |
Compute the absolute value of a value.
a | Input value |
|
constexpr |
Compute the absolute value for each element in the given vector.
v | Input vector |
|
constexpr |
Compute the absolute square of each element in the given complex vector.
For a vector of N complex elements, returns a vector of N integers
v | Input complex vector |
shift | Optional parameter to control the shift value used in the srs internally |
TR | Type of returned integer vector, default to int32 but can be set to int16 |
|
constexpr |
Compute the absolute square of each element in the given complex vector.
For a vector of N complex elements, returns a vector of N integers
v | Input complex vector |
Returns an accumulator with the element-wise addition of the input accumulator and vector.
acc | Input accumulator |
v | Input vector |
Returns an accumulator with the addition of a value to all the elements of the input vector.
acc | Input accumulator |
a | Value. The type must meet Elem. |
Returns a vector with the addition of a value to all the elements of the input vector. The type of the value and the type of the vector elements must be the same.
auto aie::add | ( | const Vec1 & | v1, |
const Vec2 & | v2 | ||
) | -> aie_dm_resource_remove_t<Vec1> |
Returns a vector with the addition of a value to all the elements of the input vector. The type of the value and the type of the vector elements must be the same.
auto aie::bit_and | ( | E | a, |
const Vec & | v | ||
) | -> aie_dm_resource_remove_t<Vec> |
Returns a vector with the bit-wise AND of a value and all the elements of the input vector. The type of the value and the type of the vector elements must be the same.
auto aie::bit_or | ( | E | a, |
const Vec & | v | ||
) | -> aie_dm_resource_remove_t<Vec> |
Returns a vector with the bit-wise OR of a value and all the elements of the input vector. The type of the value and the type of the vector elements must be the same.
auto aie::bit_xor | ( | E | a, |
const Vec & | v | ||
) | -> aie_dm_resource_remove_t<Vec> |
Returns a vector with the bit-wise XOR of a value and all the elements of the input vector. The type of the value and the type of the vector elements must be the same.
|
constexpr |
Compute the conjugate in the given complex value.
a | Input value |
auto aie::conj | ( | const Vec & | v | ) | -> aie_dm_resource_remove_t<Vec> |
Compute the conjugate for each element in the given vector of complex elements.
v | Input vector |
|
constexpr |
Returns an accumulator with the element-wise multiply-add of input vector, value and accumulator. The vector and the accumulator must have the same size and the types of all operands must be compatible. Operands can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
acc | Accumulator to which the result of the multiplication is added (or subtracted). The type must meet AccumOrOp. |
v | Input vector. The type must meet VectorOrOp. |
a | Input value. The type must meet ElemOrOp. |
|
constexpr |
Returns an accumulator with the element-wise multiply-add of the two input vectors and accumulator. The vectors and the accumulator must have the same size and their types must be compatible. Operands can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
acc | Accumulator to which the result of the multiplication is added (or subtracted). The type must meet AccumOrOp. |
v1 | First input vector. The type must meet VectorOrOp. |
v2 | Second input vector. The type must meet VectorOrOp. |
|
constexpr |
Returns an accumulator with the element-wise multiply-add of value, input vector and accumulator. The vector and the accumulator must have the same size and the types of all operands must be compatible. Operands can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
acc | Accumulator to which the result of the multiplication is added (or subtracted). The type must meet AccumOrOp. |
a | Input value. The type must meet ElemOrOp. |
v | Input vector. The type must meet VectorOrOp. |
|
constexpr |
Returns an accumulator with the addition or subtraction of the given accumulator and the element-wise square of the input vector. The vector and the accumulator must have the same size and their types must be compatible.
|
constexpr |
Returns an accumulator with the element-wise multiply-add of input vector, value and accumulator. The vector and the accumulator must have the same size and their types must be compatible. Operands can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
acc | Accumulator from which the result of the multiplication is subtracted. The type must meet Accum. |
v | Input vector. The type must meet VectorOrOp. |
a | Input value. The type must meet ElemOrOp. |
|
constexpr |
Returns an accumulator with the element-wise multiply-add of the two input vectors and accumulator. The vectors and the accumulator must have the same size and the types of all operands must be compatible. Operands can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
acc | Accumulator from which the result of the multiplication is subtracted. The type must meet Accum. |
v1 | First input vector. The type must meet VectorOrOp. |
v2 | Second input vector. The type must meet VectorOrOp. |
|
constexpr |
Returns an accumulator with the element-wise multiply-add of value, input vector and accumulator. The vector and the accumulator must have the same size and their types must be compatible. Operands can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
acc | Accumulator from which the result of the multiplication is subtracted. The type must meet Accum. |
a | Input value. The type must meet ElemOrOp. |
v | Input vector. The type must meet VectorOrOp. |
|
constexpr |
Returns an accumulator with the subtraction of the given accumulator and the element-wise square of the input vector. The vector and the accumulator must have the same size and their types must be compatible.
|
constexpr |
Returns an accumulator with the element-wise multiplication of a value and all the elements of a vector. The default accumulator accuracy is used of the input vector. The type of the value and the type of the vector elements must be compatible. Operands can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
a | Value. The type must meet ElemOrOp. |
v | Input vector. The type must meet VectorOrOp. |
|
constexpr |
Returns an accumulator of the requested type with the element-wise multiplication of a value and all the elements of the input vector. The type of the value and the type of the vector elements must be compatible. Operands can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
AccumTag | Accumulator tag that specifies the required accumulation bits. The class must be compatible with the vector types (real/complex). |
v | Input vector. The type must meet VectorOrOp. |
a | Value. The type must meet ElemOrOp. |
|
constexpr |
Returns an accumulator with the element-wise multiplication of the two input vectors. The default accumulator accuracy is used. The vectors must have the same size and compatible types. Operands can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
v1 | First input vector. The type must meet VectorOrOp. |
v2 | Second input vector. The type must meet VectorOrOp. |
|
constexpr |
Returns an accumulator of the requested type with the element-wise multiplication of the two input vectors. The vectors must have the same size and compatible types. Vectors can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
AccumTag | Accumulator tag that specifies the required accumulation bits. The class must be compatible with the vector types (real/complex). |
v1 | First input vector. The type must meet VectorOrOp. |
v2 | Second input vector. The type must meet VectorOrOp. |
|
constexpr |
Returns an accumulator with the element-wise multiplication of a value and all the elements of a vector. The default accumulator accuracy is used of the input vector. The type of the value and the type of the vector elements must be compatible. Operands can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
a | Value. The type must meet ElemOrOp. |
v | Input vector. The type must meet VectorOrOp. |
|
constexpr |
Returns an accumulator of the requested type with the element-wise multiplication of a value and all the elements of the input vector. The type of the value and the type of the vector elements must be compatible. Operands can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
AccumTag | Accumulator tag that specifies the required accumulation bits. The class must be compatible with the vector types (real/complex). |
a | Value. The type must meet ElemOrOp. |
v | Input vector. The type must meet VectorOrOp. |
|
constexpr |
Returns an accumulator with the element-wise square of the input vector. The default accumulator accuracy is used.
v | Input vector. The type must meet Vector. |
|
constexpr |
Returns an accumulator of the requested type with the element-wise square of the input vector.
AccumTag | Accumulator tag that specifies the required accumulation bits. The class must be compatible with the vector types (real/complex). |
v | Input vector. The type must meet Vector. |
|
constexpr |
For values with signed types, return the input value with the sign flipped. If the input type is unsigned, the input value is returned.
a | Input value |
|
constexpr |
For vectors with signed types, return a vector whose elements are the same as in the given vector but with the sign flipped. If the input type is unsigned, the input vector is returned.
v | Input vector |
|
constexpr |
Returns an accumulator with the negate of the element-wise multiplication of all the elements of the input vector and a value. The default accumulator accuracy is used. The vectors must have the same size and compatible types. Operands can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
v | Input vector. The type must meet VectorOrOp. |
a | Value. The type must meet ElemOrOp. |
|
constexpr |
Returns an accumulator of the requested type with the negate of the element-wise multiplication of all the elements of the input vector and a value. The type of the value and the type of the vector elements must be compatible. The input arguments can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
AccumTag | Accumulator tag that specifies the required accumulation bits. The class must be compatible with the vector types (real/complex). |
v | Input vector. The type must meet VectorOrOp. |
a | Value. The type must meet ElemOrOp. |
|
constexpr |
Returns an accumulator with the negate of the element-wise multiplication of the two input vectors. The default accumulator accuracy is used. The vectors must have the same size and compatible types. Operands can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
v1 | First input vector. The type must meet VectorOrOp. |
v2 | Second input vector. The type must meet VectorOrOp. |
|
constexpr |
Returns an accumulator of the requested type with the negate of the element-wise multiplication of the two input vectors. The vectors must have the same size and compatible types. Vectors can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
AccumTag | Accumulator tag that specifies the required accumulation bits. The class must be compatible with the vector types (real/complex). |
v1 | First input vector. The type must meet VectorOrOp. |
v2 | Second input vector. The type must meet VectorOrOp. |
|
constexpr |
Returns an accumulator with the negate of the element-wise multiplication of a value and all the elements of the input vector. The default accumulator accuracy is used. The vectors must have the same size and compatible types. Operands can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
a | Value. The type must meet ElemOrOp. |
v | Input vector. The type must meet VectorOrOp. |
|
constexpr |
Returns an accumulator of the requested type with the negate of the element-wise multiplication of a value and all the elements of the input vector. The type of the value and the type of the vector elements must be compatible. The input arguments can also be lazy operations (see Lazy Operations). On some AIE architectures certain operations can be collapsed with the multiplication into a single instruction.
AccumTag | Accumulator tag that specifies the required accumulation bits. The class must be compatible with the vector types (real/complex). |
a | Value. The type must meet ElemOrOp. |
v | Input vector. The type must meet VectorOrOp. |
auto aie::reduce_add_v | ( | const Vec & | v, |
const Others &... | others | ||
) | -> aie_dm_resource_remove_t<Vec> |
|
constexpr |
Returns an accumulator with the element-wise subtraction of the input accumulator and vector.
acc | Input accumulator (minuend) |
v | Input vector (subtrahend) |
Returns an accumulator with the subtraction of all the elements of the input accumulator and a value.
acc | Input accumulator (minuend) |
a | Value (subtrahend). The type must meet Elem. |
Returns a vector with the subtraction of the elements of the input vector and a value. The type of the value and the type of the vector elements must be the same.
v | Input vector (minuend) |
a | Value (subtrahend) |
auto aie::sub | ( | const Vec1 & | v1, |
const Vec2 & | v2 | ||
) | -> aie_dm_resource_remove_t<Vec1> |
Returns a vector with the element-wise subtraction of the two input vectors. The vectors must have the same type and size.
Returns a vector with the subtraction of a value and all the elements of the input vector. The type of the value and the type of the vector elements must be the same.