| AI Engine API User Guide (AIE-API) 2026.1

Loading...
Searching...
No Matches
Arithmetic

## Overview

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:

- Vector / Vector: the type and the size of the vectors must match. The operation is performed element-wise between the corresponding elements in each vector.
- Value / Vector: the type of the value and the type of the elements of the vector must match. The operation has the same result as if the value was broadcast to a vector and then operated with the vector argument.
- Vector element reference / Vector. Similar as Value / Vector, but using an element reference, the AIE API may optimize the operation by accessing the element directly from its original location.

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.

void add(int32 * __restrict out,
const int32 * __restrict in1, const int32 * __restrict in2, unsigned count)
{
for (unsigned i = 8; i < count; i += 8) {
aie::vector<int32, 8> vec = aie::add(aie::load_v<8>(in1 + i),
aie::load_v<8>(in2 + i));
aie::store_v(out, vec);
}
}

Operations that include a multiplication return an accumulator. The API defines a default accumulation, shown below, for each combination of types. Note that the input types are unorderded.

Default accumulator tag for different integral factor types
Type1 | int4 | int8 | int8 | int16 | int16 | int32 | cint16 | cint16 | cint16 | cint16 | cint32 | cint32 | cint32
Type2 | int8 | int8 | int16 | int16 | int32 | int32 | int16 | int32 | cint16 | cint32 | int16 | int32 | cint32
AIE |  | acc48 | acc48 | acc48 | acc48 | acc80 | cacc48 | cacc48 | cacc48 | cacc48 | cacc48 | cacc80 | cacc80
AIE-ML XDNA1 | acc32 | acc32 | acc32 | acc32 | acc64 | acc64a | cacc64 | cacc64 | cacc64 | cacc64 | cacc64 | cacc64 a | cacc64a
XDNA2 | acc32 | acc32 | acc32 | acc32 | acc64 | acc64a | cacc64 | cacc64 | cacc64 | cacc64 | cacc64 | cacc64 a | cacc64a
AIE-MLv2 | acc32 | acc32 | acc32 | acc32 | acc64 | acc64a | cacc64 | cacc64 | cacc64 | cacc64 | cacc64 | cacc64 a | cacc64a

Note
  a
    32b x 32b multiplication is not natively supported on AIE-ML/XDNA1, XDNA2, or AIE-MLv2 and is emulated using two 32b x 16b muls.

Default accumulator tag for different floating point factor types
Type1 | float8 | bfloat8 | float16 | bfloat16 | bfloat16 | cbfloat16 | float | float | cfloat | bfp16ebs8 | bfp16ebs16 | mx4 | mx6 | mx9
Type2 | float8 | bfloat8 | float16 | bfloat16 | cbfloat16 | cbfloat16 | float | cfloat | cfloat | bfp16ebs8 | bfp16ebs16 | mx4 | mx6 | mx9
AIE |  |  |  |  |  |  | accfloat | caccfloat | caccfloat |  |  |  |  |
AIE-ML XDNA1 |  |  |  | accfloat | caccfloat | caccfloat | accfloata | caccfloata | caccfloata |  |  |  |  |
XDNA2 |  |  |  | accfloat | caccfloat | caccfloat | accfloata | caccfloata | caccfloata | accfloat | accfloat |  |  |
AIE-MLv2 | accfloat | accfloat | accfloat | accfloat | caccfloat | caccfloat | accfloata | caccfloata | caccfloata |  |  | accfloat | accfloat | accfloat

Note
  a
    float multiplication is emulated on AIE-ML/XDNA1, XDNA2, and AIE-MLv2 using native bfloat16 multiplications.

Users may specify a larger number of accumulation bits by explicitly passing an accumulator tag:

// Default accumulation will be used
auto acc = aie::mul(v1, v2);
// 64b accumulation, at least, will be used
auto acc = aie::mul<acc64>(v1, v2);
// For multiply-add operations, the API uses the same accumulation as the given accumulator (cannot be overriden)
auto acc2 = aie::mac(acc, v1, v2);
aie::mul
constexpr auto mul(const Vec1 &v1, const Vec2 &v2) -> accum< AccumTag, Vec1::size()>
Returns an accumulator of the requested type with the element-wise multiplication of the two input ve...
Definition aie.hpp:4671
aie::mac
constexpr auto mac(const Acc &acc, const Vec1 &v1, const Vec2 &v2) -> operand_base_type_t< Acc >
Returns an accumulator with the element-wise multiply-add of the two input vectors and accumulator.
Definition aie.hpp:4974

## Functions
template<Elem E>
constexpr auto | aie::abs (const E &a) -> operand_base_type_t< E >
| Compute the absolute value of a value.
template<Vector Vec>
constexpr auto | aie::abs (const Vec &v) -> aie_dm_resource_remove_t< Vec >
| Compute the absolute value for each element in the given vector.
template<typename TR = float, ComplexFloatVector Vec> requires (arch::is(arch::AIE) || (arch::is(arch::AIE_ML, arch::AIE_MLv2) && __AIE_API_COMPLEX_FP32_EMULATION__ == 1))
constexpr auto | aie::abs_square (const Vec &v)
| Compute the absolute square of each element in the given complex vector.
template<typename TR = int32, ComplexIntegralVector Vec> requires (Utils::is_one_of_v<TR, int32, int16>)
constexpr auto | aie::abs_square (const Vec &v, int shift=0)
| Compute the absolute square of each element in the given complex vector.
template<AccumOrOp Acc, Vector Vec> requires (Acc::size() == Vec::size())
auto | aie::add (const Acc &acc, const Vec &v) -> result_type_t< Acc >
| Returns an accumulator with the element-wise addition of the input accumulator and vector.
template<AccumOrOp Acc, Elem E>
auto | aie::add (const Acc &acc, E a) -> result_type_t< Acc >
| Returns an accumulator with the addition of a value to all the elements of the input vector.
template<AccumOrOp Acc1, AccumOrOp Acc2> requires (arch::is(arch::Gen2) && is_same_accum_v<result_type_t<Acc1>, result_type_t<Acc2>>)
auto | aie::add (const Acc1 &acc1, const Acc2 &acc2) -> result_type_t< Acc1 >
| Returns an accumulator with the element-wise addition of the two input accumulators.
template<Vector Vec, Elem E> requires (is_valid_elem_op_v<typename Vec::value_type, E>)
auto | aie::add (const Vec &v, E a) -> aie_dm_resource_remove_t< Vec >
| Returns a vector with the addition of a value to all the elements of the input vector.
template<Vector Vec1, Vector Vec2> requires (is_same_vector_v<Vec1, Vec2>)
auto | aie::add (const Vec1 &v1, const Vec2 &v2) -> aie_dm_resource_remove_t< Vec1 >
| Returns a vector with the element-wise addition of the two input vectors.
template<Elem E, Vector Vec> requires (is_valid_elem_op_v<E, typename Vec::value_type>)
auto | aie::add (E a, const Vec &v) -> aie_dm_resource_remove_t< Vec >
| Returns a vector with the addition of a value to all the elements of the input vector.
template<ComplexElem E>
constexpr auto | aie::conj (const E &a) -> operand_base_type_t< E >
| Compute the conjugate in the given complex value.
template<ComplexVector Vec>
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.
template<ComplexVector Vec, ComplexElem E> requires (arch::is(arch::AIE) || (arch::is(arch::AIE_ML, arch::AIE_MLv2) && __AIE_API_COMPLEX_FP32_EMULATION__ == 1))
auto | aie::div (const Vec &a, const E &b) -> accum< detail::accum_tag_for_mul_types< typename Vec::value_type, detail::remove_complex_t< E > >, Vec::size()>
| Returns the quotients of the element-wise division of a complex vector 'a' by a complex scalar 'b'.
template<ComplexVector Vec> requires (arch::is(arch::AIE) || (arch::is(arch::AIE_ML, arch::AIE_MLv2) && __AIE_API_COMPLEX_FP32_EMULATION__ == 1))
auto | aie::div (const Vec &a, const Vec &b) -> accum< detail::accum_tag_for_mul_types< typename Vec::value_type, detail::remove_complex_t< typename Vec::value_type > >, Vec::size()>
| Returns the quotients of the element-wise division of two complex vectors 'a' and 'b'.
template<Vector Vec, RealElem E> requires ( detail::is_floating_point_v<typename Vec::value_type> && detail::is_valid_element_type_v<E> && detail::is_floating_point_v<E>)
auto | aie::div (const Vec &a, E b) -> accum< detail::accum_tag_for_mul_types< typename Vec::value_type, E >, Vec::size()>
| Returns the quotients of the element-wise division of each value of the first input vector by a scalar.
template<Vector Vec1, RealVector Vec2> requires (Vec1::size() == Vec2::size() && detail::is_floating_point_v<typename Vec2::value_type>)
auto | aie::div (const Vec1 &a, const Vec2 &b) -> accum< detail::accum_tag_for_mul_types< typename Vec1::value_type, typename Vec2::value_type >, Vec1::size()>
| Returns the quotients of the element-wise division of each value of the first input vector by the corresponding element in the second input vector.
template<AccumOrOp Acc, VectorOrOp Vec, ElemOrOp E> requires (is_valid_size_v<Acc, Vec, E> && is_valid_mul_op_v<typename Vec::value_type, E>)
constexpr auto | aie::mac (const Acc &acc, const Vec &v, E a) -> operand_base_type_t< Acc >
| Returns an accumulator with the element-wise multiply-add of input vector, value and accumulator.
template<AccumOrOp Acc, VectorOrOp Vec1, VectorOrOp Vec2> requires (is_valid_size_v<Acc, Vec1, Vec2> && is_valid_mul_op_v<typename Vec1::value_type, typename Vec2::value_type>)
constexpr auto | aie::mac (const Acc &acc, const Vec1 &v1, const Vec2 &v2) -> operand_base_type_t< Acc >
| Returns an accumulator with the element-wise multiply-add of the two input vectors and accumulator.
template<AccumOrOp Acc, ElemOrOp E, VectorOrOp Vec> requires (is_valid_size_v<Acc, E, Vec> && is_valid_mul_op_v<E, typename Vec::value_type>)
constexpr auto | aie::mac (const Acc &acc, E a, const Vec &v) -> operand_base_type_t< Acc >
| Returns an accumulator with the element-wise multiply-add of value, input vector and accumulator.
template<AccumOrOp Acc, Vector Vec> requires (Vec::size() == Acc::size())
constexpr auto | aie::mac_square (const Acc &acc, const Vec &v)
| Returns an accumulator with the addition or subtraction of the given accumulator and the element-wise square of the input vector.
template<AccumOrOp Acc, VectorOrOp Vec, ElemOrOp E> requires (is_valid_size_v<Acc, Vec, E> && is_valid_mul_op_v<typename Vec::value_type, E>)
constexpr auto | aie::msc (const Acc &acc, const Vec &v, E a) -> operand_base_type_t< Acc >
| Performs an element-wise multiplication of a scalar and a vector, then returns the subtraction of an accumulator with the resulting product.
template<AccumOrOp Acc, VectorOrOp Vec1, VectorOrOp Vec2> requires (is_valid_size_v<Acc, Vec1, Vec2> && is_valid_mul_op_v<typename Vec1::value_type, typename Vec2::value_type>)
constexpr auto | aie::msc (const Acc &acc, const Vec1 &v1, const Vec2 &v2) -> operand_base_type_t< Acc >
| Performs an element-wise multiplication of two input vectors, then returns the subtraction of an accumulator with the resulting product.
template<AccumOrOp Acc, ElemOrOp E, VectorOrOp Vec> requires (is_valid_size_v<Acc, E, Vec> && is_valid_mul_op_v<E, typename Vec::value_type>)
constexpr auto | aie::msc (const Acc &acc, E a, const Vec &v) -> operand_base_type_t< Acc >
| Performs an element-wise multiplication of a scalar and a vector, then returns the subtraction of an accumulator with the resulting product.
template<AccumOrOp Acc, Vector Vec> requires (Vec::size() == Acc::size())
constexpr auto | aie::msc_square (const Acc &acc, const Vec &v)
| Returns an accumulator with the subtraction of the given accumulator and the element-wise square of the input vector.
template<VectorOrOp Vec, ElemOrOp E> requires (is_valid_size_v<E, Vec> && is_valid_mul_op_v<typename Vec::value_type, E>)
constexpr auto | aie::mul (const Vec &v, E a)
| Returns an accumulator with the element-wise multiplication of a value and all the elements of a vector.
template<AccumElemBaseType AccumTag, VectorOrOp Vec, ElemOrOp E> requires (is_valid_size_v<Vec, E> && is_valid_mul_op_v<typename Vec::value_type, E>)
constexpr auto | aie::mul (const Vec &v, E a) -> accum< AccumTag, Vec::size()>
| Returns an accumulator of the requested type with the element-wise multiplication of a value and all the elements of the input vector.
template<VectorOrOp Vec1, VectorOrOp Vec2> requires (is_valid_size_v<Vec1, Vec2> && is_valid_mul_op_v<typename Vec1::value_type, typename Vec2::value_type>)
constexpr auto | aie::mul (const Vec1 &v1, const Vec2 &v2)
| Returns an accumulator with the element-wise multiplication of the two input vectors.
template<AccumElemBaseType AccumTag, VectorOrOp Vec1, VectorOrOp Vec2> requires (is_valid_size_v<Vec1, Vec2> && is_valid_mul_op_v<typename Vec1::value_type, typename Vec2::value_type>)
constexpr auto | aie::mul (const Vec1 &v1, const Vec2 &v2) -> accum< AccumTag, Vec1::size()>
| Returns an accumulator of the requested type with the element-wise multiplication of the two input vectors.
template<ElemOrOp E, VectorOrOp Vec> requires (is_valid_size_v<E, Vec> && is_valid_mul_op_v<E, typename Vec::value_type>)
constexpr auto | aie::mul (E a, const Vec &v)
| Returns an accumulator with the element-wise multiplication of a value and all the elements of a vector.
template<AccumElemBaseType AccumTag, ElemOrOp E, VectorOrOp Vec> requires (is_valid_size_v<Vec, E> && is_valid_mul_op_v<E, typename Vec::value_type>)
constexpr auto | aie::mul (E a, const Vec &v) -> accum< AccumTag, Vec::size()>
| Returns an accumulator of the requested type with the element-wise multiplication of a value and all the elements of the input vector.
template<Vector Vec>
constexpr auto | aie::mul_square (const Vec &v)
| Returns an accumulator with the element-wise square of the input vector.
template<AccumElemBaseType AccumTag, Vector Vec>
constexpr auto | aie::mul_square (const Vec &v) -> accum< AccumTag, Vec::size()>
| Returns an accumulator of the requested type with the element-wise square of the input vector.
template<Accum Acc> requires (arch::is(arch::Gen2))
constexpr auto | aie::neg (const Acc &acc) -> aie_dm_resource_remove_t< Acc >
| For accumulators, return an accumulator whose elements are the same as in the given accumulator but with the sign flipped.
template<Elem E>
constexpr auto | aie::neg (const E &a) -> operand_base_type_t< E >
| For values with signed types, return the input value with the sign flipped.
template<Vector Vec>
constexpr auto | aie::neg (const Vec &v) -> aie_dm_resource_remove_t< Vec >
| For vectors with signed types, return a vector whose elements are the same as in the given vector but with the sign flipped.
template<VectorOrOp Vec, ElemOrOp E> requires (is_valid_mul_op_v<typename Vec::value_type, E>)
constexpr auto | aie::negmul (const Vec &v, E a)
| Returns an accumulator with the negate of the element-wise multiplication of all the elements of the input vector and a value.
template<AccumElemBaseType AccumTag, VectorOrOp Vec, ElemOrOp E> requires (is_valid_mul_op_v<typename Vec::value_type, E>)
constexpr auto | aie::negmul (const Vec &v, E a) -> accum< AccumTag, Vec::size()>
| 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.
template<VectorOrOp Vec1, VectorOrOp Vec2> requires ((Vec1::size() == Vec2::size()) && is_valid_mul_op_v<typename Vec1::value_type, typename Vec2::value_type>)
constexpr auto | aie::negmul (const Vec1 &v1, const Vec2 &v2)
| Returns an accumulator with the negate of the element-wise multiplication of the two input vectors.
template<AccumElemBaseType AccumTag, VectorOrOp Vec1, VectorOrOp Vec2> requires (Vec1::size() == Vec2::size() && is_valid_mul_op_v<typename Vec1::value_type, typename Vec2::value_type>)
constexpr auto | aie::negmul (const Vec1 &v1, const Vec2 &v2) -> accum< AccumTag, Vec1::size()>
| Returns an accumulator of the requested type with the negate of the element-wise multiplication of the two input vectors.
template<ElemOrOp E, VectorOrOp Vec> requires (is_valid_mul_op_v<E, typename Vec::value_type>)
constexpr auto | aie::negmul (E a, const Vec &v)
| Returns an accumulator with the negate of the element-wise multiplication of a value and all the elements of the input vector.
template<AccumElemBaseType AccumTag, ElemOrOp E, VectorOrOp Vec> requires (is_valid_mul_op_v<E, typename Vec::value_type>)
constexpr auto | aie::negmul (E a, const Vec &v) -> accum< AccumTag, Vec::size()>
| 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.
template<Vector Vec, Vector... Others>
auto | aie::reduce_add_v (const Vec &v, const Others &... others) -> aie_dm_resource_remove_t< Vec >
| Returns the sums of the elements in the input vectors.
template<Vector Vec, Elem E> requires (is_valid_elem_op_v<E, typename Vec::value_type>)
auto | aie::saturating_add (const Vec &v, E a) -> aie_dm_resource_remove_t< Vec >
| Returns a vector with the addition of a value to all the elements of the input vector.
template<Vector Vec1, Vector Vec2> requires (is_same_vector_v<Vec1, Vec2> && !detail::is_floating_point_v<typename Vec1::value_type>)
auto | aie::saturating_add (const Vec1 &v1, const Vec2 &v2) -> aie_dm_resource_remove_t< Vec1 >
| Returns a vector with the element-wise addition of the two input vectors.
template<Elem E, Vector Vec> requires (is_valid_elem_op_v<E, typename Vec::value_type>)
auto | aie::saturating_add (E a, const Vec &v) -> aie_dm_resource_remove_t< Vec >
| Returns a vector with the addition of a value to all the elements of the input vector.
template<Vector Vec, Elem E> requires (is_valid_elem_op_v<E, typename Vec::value_type>)
auto | aie::saturating_sub (const Vec &v, E a) -> aie_dm_resource_remove_t< Vec >
| Returns a vector with the subtraction of the elements of the input vector and a value.
template<Vector Vec1, Vector Vec2> requires (is_same_vector_v<Vec1, Vec2> && !detail::is_floating_point_v<typename Vec1::value_type>)
auto | aie::saturating_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.
template<Elem E, Vector Vec> requires (is_valid_elem_op_v<E, typename Vec::value_type>)
auto | aie::saturating_sub (E a, const Vec &v) -> aie_dm_resource_remove_t< Vec >
| Returns a vector with the subtraction of a value to all the elements of the input vector.
template<AccumOrOp Acc, Vector Vec> requires (Acc::size() == Vec::size())
constexpr auto | aie::sub (const Acc &acc, const Vec &v) -> result_type_t< Acc >
| Returns an accumulator with the element-wise subtraction of the input accumulator and vector.
template<AccumOrOp Acc, Elem E>
auto | aie::sub (const Acc &acc, E a) -> result_type_t< Acc >
| Returns an accumulator with the subtraction of all the elements of the input accumulator and a value.
template<AccumOrOp Acc1, AccumOrOp Acc2> requires (arch::is(arch::Gen2) && is_same_accum_v<result_type_t<Acc1>, result_type_t<Acc2>>)
auto | aie::sub (const Acc1 &acc1, const Acc2 &acc2) -> result_type_t< Acc1 >
| Returns an accumulator with the element-wise subtraction of the two input accumulators.
template<Vector Vec, Elem E> requires (is_valid_elem_op_v<E, typename Vec::value_type>)
auto | aie::sub (const Vec &v, E a) -> aie_dm_resource_remove_t< Vec >
| Returns a vector with the subtraction of the elements of the input vector and a value.
template<Vector Vec1, Vector Vec2> requires (is_same_vector_v<Vec1, Vec2>)
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.
template<Elem E, Vector Vec> requires (is_valid_elem_op_v<E, typename Vec::value_type>)
auto | aie::sub (E a, const Vec &v) -> aie_dm_resource_remove_t< Vec >
| Returns a vector with the subtraction of a value and all the elements of the input vector.

## Function Documentation

## ◆ abs() [1/2]

template<Elem E>

auto aie::abs | ( | const E & | a | ) | ->operand_base_type_t< E >
| constexpr

Compute the absolute value of a value.

Parameters

  a | Input value

## ◆ abs() [2/2]

template<Vector Vec>

auto aie::abs | ( | const Vec & | v | ) | ->aie_dm_resource_remove_t< Vec >
| constexpr

Compute the absolute value for each element in the given vector.

Parameters

  v | Input vector

## ◆ abs_square() [1/2]

template<typename TR = float, ComplexFloatVector Vec>
requires (arch::is(arch::AIE) || (arch::is(arch::AIE_ML, arch::AIE_MLv2) && __AIE_API_COMPLEX_FP32_EMULATION__ == 1))

auto aie::abs_square | ( | const Vec & | v | ) |
| 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

for (unsigned i = 0; i < Elems; ++i)
out[i] = v[i].real² + v[i].imag²;

Parameters

  v | Input complex vector

## ◆ abs_square() [2/2]

template<typename TR = int32, ComplexIntegralVector Vec>
requires (Utils::is_one_of_v<TR, int32, int16>)

auto aie::abs_square | ( | const Vec & | v,
|  | int | shift = 0 )
| 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

for (unsigned i = 0; i < Elems; ++i)
out[i] = v[i].real² + v[i].imag²;

Parameters

  v | Input complex vector
  shift | Optional parameter to control the shift value used in the srs internally

Template Parameters

  TR | Type of returned integer vector, default to int32 but can be set to int16

## ◆ add() [1/6]

template<AccumOrOp Acc, Vector Vec>
requires (Acc::size() == Vec::size())

auto aie::add | ( | const Acc & | acc,
|  | const Vec & | v )->result_type_t< Acc >

Returns an accumulator with the element-wise addition of the input accumulator and vector.

for (unsigned i = 0; i < Elems; ++i)
out[i] = acc[i] + v[i];

Parameters

  acc | Input accumulator
  v | Input vector

## ◆ add() [2/6]

template<AccumOrOp Acc, Elem E>

auto aie::add | ( | const Acc & | acc,
|  | E | a )->result_type_t< Acc >

Returns an accumulator with the addition of a value to all the elements of the input vector.

for (unsigned i = 0; i < Elems; ++i)
out[i] = acc[i] + a;
aie_dm_resource::a
@ a
Memory access is bound to resource a.
Definition aie_doc.hpp:1380

Parameters

  acc | Input accumulator
  a | Value. The type must meet aie::Elem.

## ◆ add() [3/6]

template<AccumOrOp Acc1, AccumOrOp Acc2>
requires (arch::is(arch::Gen2) && is_same_accum_v<result_type_t<Acc1>, result_type_t<Acc2>>)

auto aie::add | ( | const Acc1 & | acc1,
|  | const Acc2 & | acc2 )->result_type_t< Acc1 >

Returns an accumulator with the element-wise addition of the two input accumulators.

for (unsigned i = 0; i < Elems; ++i)
out[i] = acc1[i] + acc2[i];

Parameters

  acc1 | First input accumulator. The type must meet aie::AccumOrOp.
  acc2 | Second input accumulator. The type must meet aie::AccumOrOp.

## ◆ add() [4/6]

template<Vector Vec, Elem E>
requires (is_valid_elem_op_v<typename Vec::value_type, E>)

auto aie::add | ( | const Vec & | v,
|  | E | a )->aie_dm_resource_remove_t< Vec >

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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = v[i] + a;

Parameters

  v | Input vector. The type must meet aie::Vector.
  a | Value. The type must meet aie::Elem.

## ◆ add() [5/6]

template<Vector Vec1, Vector Vec2>
requires (is_same_vector_v<Vec1, Vec2>)

auto aie::add | ( | const Vec1 & | v1,
|  | const Vec2 & | v2 )->aie_dm_resource_remove_t< Vec1 >

Returns a vector with the element-wise addition of the two input vectors.

The vectors must have the same type and size.

for (unsigned i = 0; i < Elems; ++i)
out[i] = v1[i] + v2[i];

Parameters

  v1 | First input vector. The type must meet aie::Vector.
  v2 | Second input vector. The type must meet aie::Vector.

## ◆ add() [6/6]

template<Elem E, Vector Vec>
requires (is_valid_elem_op_v<E, typename Vec::value_type>)

auto aie::add | ( | E | a,
|  | const Vec & | v )->aie_dm_resource_remove_t< Vec >

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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = a + v[i];

Parameters

  a | Value. The type must meet aie::Elem.
  v | Input vector. The type must meet aie::Vector.

## ◆ conj() [1/2]

template<ComplexElem E>

auto aie::conj | ( | const E & | a | ) | ->operand_base_type_t< E >
| constexpr

Compute the conjugate in the given complex value.

Parameters

  a | Input value

## ◆ conj() [2/2]

template<ComplexVector Vec>

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.

Parameters

  v | Input vector

## ◆ div() [1/4]

template<ComplexVector Vec, ComplexElem E>
requires (arch::is(arch::AIE) || (arch::is(arch::AIE_ML, arch::AIE_MLv2) && __AIE_API_COMPLEX_FP32_EMULATION__ == 1))

auto aie::div | ( | const Vec & | a,
|  | const E & | b )->accum< detail::accum_tag_for_mul_types< typenameVec::value_type, detail::remove_complex_t< E > >, Vec::size()>

Returns the quotients of the element-wise division of a complex vector 'a' by a complex scalar 'b'.

for (unsigned i = 0; i < Elems; ++i)
out[i] = a[i] / b;
aie_dm_resource::b
@ b
Memory access is bound to resource b.
Definition aie_doc.hpp:1381

Parameters

  a | Vector of dividends. The type must meet aie::ComplexVector.
  b | Divisor. The type must meet aie::ComplexElem.

## ◆ div() [2/4]

template<ComplexVector Vec>
requires (arch::is(arch::AIE) || (arch::is(arch::AIE_ML, arch::AIE_MLv2) && __AIE_API_COMPLEX_FP32_EMULATION__ == 1))

auto aie::div | ( | const Vec & | a,
|  | const Vec & | b )->accum< detail::accum_tag_for_mul_types< typenameVec::value_type, detail::remove_complex_t< typenameVec::value_type > >, Vec::size()>

Returns the quotients of the element-wise division of two complex vectors 'a' and 'b'.

for (unsigned i = 0; i < Elems; ++i)
out[i] = a[i] / b[i];

Complex division is achieved by multiplying both dividend and divisor by the conjugate of the divisor:

a = A + Bi; b = C + Di
a/b = (A + Bi) / (C + Di) = ((A + Bi) * (C - Di)) / ((C + Di) * (C - Di))
= ((A + Bi) * (C - Di)) / (C^2 + D^2)

Parameters

  a | Vector of dividends. The type must meet aie::ComplexVector.
  b | Vector of divisors. The type must meet aie::ComplexVector.

## ◆ div() [3/4]

template<Vector Vec, RealElem E>
requires ( detail::is_floating_point_v<typename Vec::value_type> && detail::is_valid_element_type_v<E> && detail::is_floating_point_v<E>)

auto aie::div | ( | const Vec & | a,
|  | E | b )->accum< detail::accum_tag_for_mul_types< typenameVec::value_type, E >, Vec::size()>

Returns the quotients of the element-wise division of each value of the first input vector by a scalar.

for (unsigned i = 0; i < Elems; ++i)
out[i] = a[i] / b;

Parameters

  a | Vector of dividends. The type must meet aie::Vector.
  b | Divisor. The type must meet aie::RealElem.

## ◆ div() [4/4]

template<Vector Vec1, RealVector Vec2>
requires (Vec1::size() == Vec2::size() && detail::is_floating_point_v<typename Vec2::value_type>)

auto aie::div | ( | const Vec1 & | a,
|  | const Vec2 & | b )->accum< detail::accum_tag_for_mul_types< typenameVec1::value_type, typenameVec2::value_type >, Vec1::size()>

Returns the quotients of the element-wise division of each value of the first input vector by the corresponding element in the second input vector.

for (unsigned i = 0; i < Elems; ++i)
out[i] = a[i] / b[i];

Parameters

  a | Vector of dividends. The type must meet aie::Vector.
  b | Vector of divisors. The type must meet aie::RealVector.

## ◆ mac() [1/3]

template<AccumOrOp Acc, VectorOrOp Vec, ElemOrOp E>
requires (is_valid_size_v<Acc, Vec, E> && is_valid_mul_op_v<typename Vec::value_type, E>)

auto aie::mac | ( | const Acc & | acc,
|  | const Vec & | v,
|  | E | a )->operand_base_type_t< Acc >
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = acc[i] + op1(v[i]) * op2(a);

Parameters

  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 aie::VectorOrOp.
  a | Input value. The type must meet aie::ElemOrOp.

## ◆ mac() [2/3]

template<AccumOrOp Acc, VectorOrOp Vec1, VectorOrOp Vec2>
requires (is_valid_size_v<Acc, Vec1, Vec2> && is_valid_mul_op_v<typename Vec1::value_type, typename Vec2::value_type>)

auto aie::mac | ( | const Acc & | acc,
|  | const Vec1 & | v1,
|  | const Vec2 & | v2 )->operand_base_type_t< Acc >
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = acc[i] + op1(v1[i]) * op2(v2[i]);

Parameters

  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 aie::VectorOrOp.
  v2 | Second input vector. The type must meet aie::VectorOrOp.

## ◆ mac() [3/3]

template<AccumOrOp Acc, ElemOrOp E, VectorOrOp Vec>
requires (is_valid_size_v<Acc, E, Vec> && is_valid_mul_op_v<E, typename Vec::value_type>)

auto aie::mac | ( | const Acc & | acc,
|  | E | a,
|  | const Vec & | v )->operand_base_type_t< Acc >
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = acc[i] + op1(a) * op2(v[i]);

Parameters

  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 aie::ElemOrOp.
  v | Input vector. The type must meet aie::VectorOrOp.

## ◆ mac_square()

template<AccumOrOp Acc, Vector Vec>
requires (Vec::size() == Acc::size())

auto aie::mac_square | ( | const Acc & | acc,
|  | const Vec & | v )
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = acc[i] + v[i] * v[i];

Parameters

  acc | Input accumulator. The type must meet aie::AccumOrOp.
  v | Input vector. The type must meet aie::Vector.

## ◆ msc() [1/3]

template<AccumOrOp Acc, VectorOrOp Vec, ElemOrOp E>
requires (is_valid_size_v<Acc, Vec, E> && is_valid_mul_op_v<typename Vec::value_type, E>)

auto aie::msc | ( | const Acc & | acc,
|  | const Vec & | v,
|  | E | a )->operand_base_type_t< Acc >
| constexpr

Performs an element-wise multiplication of a scalar and a vector, then returns the subtraction of an accumulator with the resulting product.

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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = acc[i] - op1(v[i]) * op2(a);

Parameters

  acc | Accumulator from which the result of the multiplication is subtracted. The type must meet aie::Accum.
  v | Input vector. The type must meet aie::VectorOrOp.
  a | Input value. The type must meet aie::ElemOrOp.

## ◆ msc() [2/3]

template<AccumOrOp Acc, VectorOrOp Vec1, VectorOrOp Vec2>
requires (is_valid_size_v<Acc, Vec1, Vec2> && is_valid_mul_op_v<typename Vec1::value_type, typename Vec2::value_type>)

auto aie::msc | ( | const Acc & | acc,
|  | const Vec1 & | v1,
|  | const Vec2 & | v2 )->operand_base_type_t< Acc >
| constexpr

Performs an element-wise multiplication of two input vectors, then returns the subtraction of an accumulator with the resulting product.

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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = acc[i] - op1(v1[i]) * op2(v2[i]);

Parameters

  acc | Accumulator from which the result of the multiplication is subtracted. The type must meet aie::Accum.
  v1 | First input vector. The type must meet aie::VectorOrOp.
  v2 | Second input vector. The type must meet aie::VectorOrOp.

## ◆ msc() [3/3]

template<AccumOrOp Acc, ElemOrOp E, VectorOrOp Vec>
requires (is_valid_size_v<Acc, E, Vec> && is_valid_mul_op_v<E, typename Vec::value_type>)

auto aie::msc | ( | const Acc & | acc,
|  | E | a,
|  | const Vec & | v )->operand_base_type_t< Acc >
| constexpr

Performs an element-wise multiplication of a scalar and a vector, then returns the subtraction of an accumulator with the resulting product.

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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = acc[i] - op1(a) * op2(v[i]);

Parameters

  acc | Accumulator from which the result of the multiplication is subtracted. The type must meet aie::Accum.
  a | Input value. The type must meet aie::ElemOrOp.
  v | Input vector. The type must meet aie::VectorOrOp.

## ◆ msc_square()

template<AccumOrOp Acc, Vector Vec>
requires (Vec::size() == Acc::size())

auto aie::msc_square | ( | const Acc & | acc,
|  | const Vec & | v )
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = acc[i] - v[i] * v[i];

Parameters

  acc | Input accumulator. The type must meet aie::Accum.
  v | Input vector. The type must meet aie::Vector.

## ◆ mul() [1/6]

template<VectorOrOp Vec, ElemOrOp E>
requires (is_valid_size_v<E, Vec> && is_valid_mul_op_v<typename Vec::value_type, E>)

auto aie::mul | ( | const Vec & | v,
|  | E | a )
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = op1(v[i]) * op2(a);

Parameters

  a | Value. The type must meet aie::ElemOrOp.
  v | Input vector. The type must meet aie::VectorOrOp.

## ◆ mul() [2/6]

template<AccumElemBaseType AccumTag, VectorOrOp Vec, ElemOrOp E>
requires (is_valid_size_v<Vec, E> && is_valid_mul_op_v<typename Vec::value_type, E>)

auto aie::mul | ( | const Vec & | v,
|  | E | a )->accum< AccumTag, Vec::size()>
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = op1(v[i]) * op2(a);

Template Parameters

  AccumTag | Accumulator tag that specifies the required accumulation bits. The class must be compatible with the vector types (real/complex). Refer to default accumulator tag table for the minimum accumulator element tag required for each combination of input element types.

Parameters

  v | Input vector. The type must meet aie::VectorOrOp.
  a | Value. The type must meet aie::ElemOrOp.

## ◆ mul() [3/6]

template<VectorOrOp Vec1, VectorOrOp Vec2>
requires (is_valid_size_v<Vec1, Vec2> && is_valid_mul_op_v<typename Vec1::value_type, typename Vec2::value_type>)

auto aie::mul | ( | const Vec1 & | v1,
|  | const Vec2 & | v2 )
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = op1(v1[i]) * op2(v2[i]);

Parameters

  v1 | First input vector. The type must meet aie::VectorOrOp.
  v2 | Second input vector. The type must meet aie::VectorOrOp.

## ◆ mul() [4/6]

template<AccumElemBaseType AccumTag, VectorOrOp Vec1, VectorOrOp Vec2>
requires (is_valid_size_v<Vec1, Vec2> && is_valid_mul_op_v<typename Vec1::value_type, typename Vec2::value_type>)

auto aie::mul | ( | const Vec1 & | v1,
|  | const Vec2 & | v2 )->accum< AccumTag, Vec1::size()>
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = op1(v1[i]) * op2(v2[i]);

Template Parameters

  AccumTag | Accumulator tag that specifies the required accumulation bits. The class must be compatible with the vector types (real/complex). Refer to default accumulator tag table for the minimum accumulator element tag required for each combination of input element types.

Parameters

  v1 | First input vector. The type must meet aie::VectorOrOp.
  v2 | Second input vector. The type must meet aie::VectorOrOp.

## ◆ mul() [5/6]

template<ElemOrOp E, VectorOrOp Vec>
requires (is_valid_size_v<E, Vec> && is_valid_mul_op_v<E, typename Vec::value_type>)

auto aie::mul | ( | E | a,
|  | const Vec & | v )
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = op1(a) * op2(v[i]);

Parameters

  a | Value. The type must meet aie::ElemOrOp.
  v | Input vector. The type must meet aie::VectorOrOp.

## ◆ mul() [6/6]

template<AccumElemBaseType AccumTag, ElemOrOp E, VectorOrOp Vec>
requires (is_valid_size_v<Vec, E> && is_valid_mul_op_v<E, typename Vec::value_type>)

auto aie::mul | ( | E | a,
|  | const Vec & | v )->accum< AccumTag, Vec::size()>
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = op1(a) * op2(v[i]);

Template Parameters

  AccumTag | Accumulator tag that specifies the required accumulation bits. The class must be compatible with the vector types (real/complex). Refer to default accumulator tag table for the minimum accumulator element tag required for each combination of input element types.

Parameters

  a | Value. The type must meet aie::ElemOrOp.
  v | Input vector. The type must meet aie::VectorOrOp.

## ◆ mul_square() [1/2]

template<Vector Vec>

auto aie::mul_square | ( | const Vec & | v | ) |
| constexpr

Returns an accumulator with the element-wise square of the input vector.

The default accumulator accuracy is used.

for (unsigned i = 0; i < Elems; ++i)
out[i] = v[i] * v[i];

Parameters

  v | Input vector. The type must meet aie::Vector.

## ◆ mul_square() [2/2]

template<AccumElemBaseType AccumTag, Vector Vec>

auto aie::mul_square | ( | const Vec & | v | ) | ->accum< AccumTag, Vec::size()>
| constexpr

Returns an accumulator of the requested type with the element-wise square of the input vector.

for (unsigned i = 0; i < Elems; ++i)
out[i] = v[i] * v[i];

Template Parameters

  AccumTag | Accumulator tag that specifies the required accumulation bits. The class must be compatible with the vector types (real/complex). Refer to default accumulator tag table for the minimum accumulator element tag required for each combination of input element types.

Parameters

  v | Input vector. The type must meet aie::Vector.

## ◆ neg() [1/3]

template<Accum Acc>
requires (arch::is(arch::Gen2))

auto aie::neg | ( | const Acc & | acc | ) | ->aie_dm_resource_remove_t< Acc >
| constexpr

For accumulators, return an accumulator whose elements are the same as in the given accumulator but with the sign flipped.

Parameters

  acc | Input accumulator

## ◆ neg() [2/3]

template<Elem E>

auto aie::neg | ( | const E & | a | ) | ->operand_base_type_t< E >
| 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.

Parameters

  a | Input value

## ◆ neg() [3/3]

template<Vector Vec>

auto aie::neg | ( | const Vec & | v | ) | ->aie_dm_resource_remove_t< Vec >
| 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.

Parameters

  v | Input vector

## ◆ negmul() [1/6]

template<VectorOrOp Vec, ElemOrOp E>
requires (is_valid_mul_op_v<typename Vec::value_type, E>)

auto aie::negmul | ( | const Vec & | v,
|  | E | a )
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = -(op1(v[i]) * op2(a)));

Parameters

  v | Input vector. The type must meet aie::VectorOrOp.
  a | Value. The type must meet aie::ElemOrOp.

## ◆ negmul() [2/6]

template<AccumElemBaseType AccumTag, VectorOrOp Vec, ElemOrOp E>
requires (is_valid_mul_op_v<typename Vec::value_type, E>)

auto aie::negmul | ( | const Vec & | v,
|  | E | a )->accum< AccumTag, Vec::size()>
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = -(op1(v[i]) * op2(a));

Template Parameters

  AccumTag | Accumulator tag that specifies the required accumulation bits. The class must be compatible with the vector types (real/complex). Refer to default accumulator tag table for the minimum accumulator element tag required for each combination of input element types.

Parameters

  v | Input vector. The type must meet aie::VectorOrOp.
  a | Value. The type must meet aie::ElemOrOp.

## ◆ negmul() [3/6]

template<VectorOrOp Vec1, VectorOrOp Vec2>
requires ((Vec1::size() == Vec2::size()) && is_valid_mul_op_v<typename Vec1::value_type, typename Vec2::value_type>)

auto aie::negmul | ( | const Vec1 & | v1,
|  | const Vec2 & | v2 )
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = -(op1(v1[i]) * op2(v2[i]));

Parameters

  v1 | First input vector. The type must meet aie::VectorOrOp.
  v2 | Second input vector. The type must meet aie::VectorOrOp.

## ◆ negmul() [4/6]

template<AccumElemBaseType AccumTag, VectorOrOp Vec1, VectorOrOp Vec2>
requires (Vec1::size() == Vec2::size() && is_valid_mul_op_v<typename Vec1::value_type, typename Vec2::value_type>)

auto aie::negmul | ( | const Vec1 & | v1,
|  | const Vec2 & | v2 )->accum< AccumTag, Vec1::size()>
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = -(op1(v1[i]) * op1(v2[i]));

Template Parameters

  AccumTag | Accumulator tag that specifies the required accumulation bits. The class must be compatible with the vector types (real/complex). Refer to default accumulator tag table for the minimum accumulator element tag required for each combination of input element types.

Parameters

  v1 | First input vector. The type must meet aie::VectorOrOp.
  v2 | Second input vector. The type must meet aie::VectorOrOp.

## ◆ negmul() [5/6]

template<ElemOrOp E, VectorOrOp Vec>
requires (is_valid_mul_op_v<E, typename Vec::value_type>)

auto aie::negmul | ( | E | a,
|  | const Vec & | v )
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = -(op1(a) * op2(v[i]));

Parameters

  a | Value. The type must meet aie::ElemOrOp.
  v | Input vector. The type must meet aie::VectorOrOp.

## ◆ negmul() [6/6]

template<AccumElemBaseType AccumTag, ElemOrOp E, VectorOrOp Vec>
requires (is_valid_mul_op_v<E, typename Vec::value_type>)

auto aie::negmul | ( | E | a,
|  | const Vec & | v )->accum< AccumTag, Vec::size()>
| 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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = -(op1(a) * op2(v[i]));

Template Parameters

  AccumTag | Accumulator tag that specifies the required accumulation bits. The class must be compatible with the vector types (real/complex). Refer to default accumulator tag table for the minimum accumulator element tag required for each combination of input element types.

Parameters

  a | Value. The type must meet aie::ElemOrOp.
  v | Input vector. The type must meet aie::VectorOrOp.

## ◆ reduce_add_v()

template<Vector Vec, Vector... Others>

auto aie::reduce_add_v | ( | const Vec & | v,
|  | const Others &... | others )->aie_dm_resource_remove_t< Vec >

Returns the sums of the elements in the input vectors.

The sum of each input vector is stored in an element of the output vector.

Parameters

  v | First input vector. The type must meet aie::Vector.
  others | Remaining input vectors. The type must meet aie::Vector.

## ◆ saturating_add() [1/3]

template<Vector Vec, Elem E>
requires (is_valid_elem_op_v<E, typename Vec::value_type>)

auto aie::saturating_add | ( | const Vec & | v,
|  | E | a )->aie_dm_resource_remove_t< Vec >

Returns a vector with the addition of a value to all the elements of the input vector.

The behaviour of the addition is dictated by the saturation mode The type of the value and the type of the vector elements must be the same.

for (unsigned i = 0; i < Elems; ++i)
out[i] = v[i] + a;

Parameters

  v | Input vector. The type must meet aie::Vector.
  a | Value. The type must meet aie::Elem.

## ◆ saturating_add() [2/3]

template<Vector Vec1, Vector Vec2>
requires (is_same_vector_v<Vec1, Vec2> && !detail::is_floating_point_v<typename Vec1::value_type>)

auto aie::saturating_add | ( | const Vec1 & | v1,
|  | const Vec2 & | v2 )->aie_dm_resource_remove_t< Vec1 >

Returns a vector with the element-wise addition of the two input vectors.

The behaviour of the addition is dictated by the saturation mode The vectors must have the same type and size.

for (unsigned i = 0; i < Elems; ++i)
out[i] = v1[i] + v2[i];

Parameters

  v1 | First input vector. The type must meet aie::Vector.
  v2 | Second input vector. The type must meet aie::Vector.

## ◆ saturating_add() [3/3]

template<Elem E, Vector Vec>
requires (is_valid_elem_op_v<E, typename Vec::value_type>)

auto aie::saturating_add | ( | E | a,
|  | const Vec & | v )->aie_dm_resource_remove_t< Vec >

Returns a vector with the addition of a value to all the elements of the input vector.

The behaviour of the addition is dictated by the saturation mode The type of the value and the type of the vector elements must be the same.

for (unsigned i = 0; i < Elems; ++i)
out[i] = a + v[i];

Parameters

  a | Value. The type must meet aie::Elem.
  v | Input vector. The type must meet aie::Vector.

## ◆ saturating_sub() [1/3]

template<Vector Vec, Elem E>
requires (is_valid_elem_op_v<E, typename Vec::value_type>)

auto aie::saturating_sub | ( | const Vec & | v,
|  | E | a )->aie_dm_resource_remove_t< Vec >

Returns a vector with the subtraction of the elements of the input vector and a value.

The behaviour of the subtraction is dictated by the saturation mode The type of the value and the type of the vector elements must be the same.

for (unsigned i = 0; i < Elems; ++i)
out[i] = v[i] - a;

Parameters

  v | Input vector (subtrahend). The type must meet aie::Vector.
  a | Value (minuend). The type must meet aie::Elem.

## ◆ saturating_sub() [2/3]

template<Vector Vec1, Vector Vec2>
requires (is_same_vector_v<Vec1, Vec2> && !detail::is_floating_point_v<typename Vec1::value_type>)

auto aie::saturating_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 behaviour of the subtraction is dictated by the saturation mode The vectors must have the same type and size.

for (unsigned i = 0; i < Elems; ++i)
out[i] = v1[i] - v2[i];

Parameters

  v1 | First input vector. The type must meet aie::Vector.
  v2 | Second input vector. The type must meet aie::Vector.

## ◆ saturating_sub() [3/3]

template<Elem E, Vector Vec>
requires (is_valid_elem_op_v<E, typename Vec::value_type>)

auto aie::saturating_sub | ( | E | a,
|  | const Vec & | v )->aie_dm_resource_remove_t< Vec >

Returns a vector with the subtraction of a value to all the elements of the input vector.

The behaviour of the subtraction is dictated by the saturation mode The type of the value and the type of the vector elements must be the same.

for (unsigned i = 0; i < Elems; ++i)
out[i] = a - v[i];

Parameters

  a | Value (minuend). The type must meet aie::Elem.
  v | Input vector (subtrahend). The type must meet aie::Vector.

## ◆ sub() [1/6]

template<AccumOrOp Acc, Vector Vec>
requires (Acc::size() == Vec::size())

auto aie::sub | ( | const Acc & | acc,
|  | const Vec & | v )->result_type_t< Acc >
| constexpr

Returns an accumulator with the element-wise subtraction of the input accumulator and vector.

for (unsigned i = 0; i < Elems; ++i)
out[i] = acc[i] - v[i];

Parameters

  acc | Input accumulator (minuend)
  v | Input vector (subtrahend)

## ◆ sub() [2/6]

template<AccumOrOp Acc, Elem E>

auto aie::sub | ( | const Acc & | acc,
|  | E | a )->result_type_t< Acc >

Returns an accumulator with the subtraction of all the elements of the input accumulator and a value.

for (unsigned i = 0; i < Elems; ++i)
out[i] = acc[i] - a;

Parameters

  acc | Input accumulator (minuend)
  a | Value (subtrahend). The type must meet aie::Elem.

## ◆ sub() [3/6]

template<AccumOrOp Acc1, AccumOrOp Acc2>
requires (arch::is(arch::Gen2) && is_same_accum_v<result_type_t<Acc1>, result_type_t<Acc2>>)

auto aie::sub | ( | const Acc1 & | acc1,
|  | const Acc2 & | acc2 )->result_type_t< Acc1 >

Returns an accumulator with the element-wise subtraction of the two input accumulators.

for (unsigned i = 0; i < Elems; ++i)
out[i] = acc1[i] - acc2[i];

Parameters

  acc1 | First input accumulator. The type must meet aie::AccumOrOp.
  acc2 | Second input accumulator. The type must meet aie::AccumOrOp.

## ◆ sub() [4/6]

template<Vector Vec, Elem E>
requires (is_valid_elem_op_v<E, typename Vec::value_type>)

auto aie::sub | ( | const Vec & | v,
|  | E | a )->aie_dm_resource_remove_t< Vec >

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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = v[i] - a;

Parameters

  v | Input vector (subtrahend). The type must meet aie::Vector.
  a | Value (minuend). The type must meet aie::Elem.

## ◆ sub() [5/6]

template<Vector Vec1, Vector Vec2>
requires (is_same_vector_v<Vec1, Vec2>)

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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = v1[i] - v2[i];

Parameters

  v1 | First input vector (minuend). The type must meet aie::Vector.
  v2 | Second input vector (subtrahend). The type must meet aie::Vector.

## ◆ sub() [6/6]

template<Elem E, Vector Vec>
requires (is_valid_elem_op_v<E, typename Vec::value_type>)

auto aie::sub | ( | E | a,
|  | const Vec & | v )->aie_dm_resource_remove_t< Vec >

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.

for (unsigned i = 0; i < Elems; ++i)
out[i] = a - v[i];

Parameters

  a | Value (minuend). The type must meet aie::Elem.
  v | Input vector (subtrahend). The type must meet aie::Vector.