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

Loading...
Searching...
No Matches
Lazy Operations
Basic Types

## Overview

AIE architectures offer multiplication instructions that can perform additional operations on on the input arguments.

Instead of adding one variant for each possible combination, AIE API offers types that can wrap an existing vector, accumulator of element reference and be passed into the multiplication function. Then the API will merge the operations into a single instruction or apply the operation on the vector before the multiplication, depending on the hardware support,

The following example performs an element-wise multiplication of the absolute of vector a and the conjugate of vector b.

aie::accum<cacc48, 16> mul_conj(aie::vector<int16, 16> a, aie::vector<cint16, 16> b)
{
aie::accum<cacc48, 16> ret;
ret = aie::mul(aie::op_abs(a), aie::op_conj(b));
return ret;
}

## Functions
template<typename T> requires (RealVector<T> || RealElem<T> || is_real_op_v<T>)
constexpr unary_op< T, Operation::Abs > | aie::op_abs (const T &e)
| Returns an absolute operation modifier for the given vector or element.
template<Accum Acc>
constexpr unary_op< Acc, Operation::Acc_Add > | aie::op_add (const Acc &acc)
| Returns an addition operation modifier for the given accumulator.
template<typename T> requires (ComplexVector<T> || ComplexElem<T> || is_complex_op_v<T>)
constexpr unary_op< T, Operation::Conj > | aie::op_conj (const T &e)
| Returns a conjugate operation modifier for the given complex vector or element.
template<VectorOrOp Vec1, VectorOrOp Vec2>
constexpr binary_op< Vec1, Vec2, Operation::Max > | aie::op_max (const Vec1 &a, const Vec2 &b)
| Returns a maximum operation modifier for the given pair of vectors or elements.
template<VectorOrOp Vec1, VectorOrOp Vec2>
constexpr binary_op< Vec1, Vec2, Operation::Min > | aie::op_min (const Vec1 &a, const Vec2 &b)
| Returns a minimum operation modifier for the given pair of vectors or elements.
template<typename T> requires (Vector<T> || Elem<T> || Accum<T> || is_op_v<T>)
constexpr binary_op< T, bool, Operation::Neg > | aie::op_neg (const T &e, bool to_negate)
| Conditionally negates the operand based on the to_negate parameter.
template<typename T> requires (Vector<T> || SparseVector<T> || Elem<T> || Accum<T>)
constexpr unary_op< T, Operation::None > | aie::op_none (const T &e)
| Returns an empty operation modifier for the given vector, vector element or accumulator.
template<TensorBufferStream T>
unary_op< T, Operation::None > | aie::op_none (T &e)
| Returns an empty operation modifier for the given tensor buffer stream.
template<typename T>
auto | aie::op_or_none (T &&arg)
| Returns an empty operation modifier for the given input argument when it is not an operation already and when it is it returns the input itself.
template<typename T> requires ((Vector<T> || SparseVector<T> || Elem<T> || Accum<T> || is_op_v<T>) && (!detail::is_complex_v<typename T::value_type>) && (!detail::is_floating_point_v<typename T::value_type>))
constexpr binary_op< T, bool, Operation::Sign > | aie::op_sign (const T &e, bool is_signed)
| Returns dynamically signed/unsigned operation modifier for the vector or element, based on the boolean parameter.
template<TensorBufferStream T>
binary_op< T, bool, Operation::Sign > | aie::op_sign (T &e, bool is_signed)
| Returns dynamically signed/unsigned operation modifier for the given tensor buffer stream.
template<Accum Acc>
constexpr unary_op< Acc, Operation::Acc_Sub > | aie::op_sub (const Acc &acc)
| Returns a subtraction operation modifier for the given accumulator.
template<Accum Acc>
constexpr binary_op< Acc, bool, Operation::Zero > | aie::op_zero (const Acc &acc, bool to_zero)
| Zeroes out the given accumulator or not depending on the zero parameter.

## Function Documentation

## ◆ op_abs()

template<typename T>
requires (RealVector<T> || RealElem<T> || is_real_op_v<T>)

unary_op< T, Operation::Abs > aie::op_abs | ( | const T & | e | ) |
| constexpr

Returns an absolute operation modifier for the given vector or element.

On some architecture versions, this operation can be collapsed with a subsequent multiplication.

Parameters

  e | Vector or element to which the operation is performed. The type must meet aie::RealVector or aie::RealElem.

## ◆ op_add()

template<Accum Acc>

unary_op< Acc, Operation::Acc_Add > aie::op_add | ( | const Acc & | acc | ) |
| constexpr

Returns an addition operation modifier for the given accumulator.

Parameters

  acc | Accumulator to which the operation is performed.

## ◆ op_conj()

template<typename T>
requires (ComplexVector<T> || ComplexElem<T> || is_complex_op_v<T>)

unary_op< T, Operation::Conj > aie::op_conj | ( | const T & | e | ) |
| constexpr

Returns a conjugate operation modifier for the given complex vector or element.

On some architecture versions, this operation can be collapsed with a subsequent multiplication.

Parameters

  e | Vector or element to which the operation is performed. The type must meet aie::ComplexVector or aie::ComplexElem.

## ◆ op_max()

template<VectorOrOp Vec1, VectorOrOp Vec2>

binary_op< Vec1, Vec2, Operation::Max > aie::op_max | ( | const Vec1 & | a,
|  | const Vec2 & | b )
| constexpr

Returns a maximum operation modifier for the given pair of vectors or elements.

On some architecture versions, this operation can be collapsed with a subsequent multiplication.

Parameters

  a | First vector or element passed to the operation. The type must meet aie::Vector or aie::Elem.
  b | Second vector or element passed to the operation. The type must be the same as for a.

## ◆ op_min()

template<VectorOrOp Vec1, VectorOrOp Vec2>

binary_op< Vec1, Vec2, Operation::Min > aie::op_min | ( | const Vec1 & | a,
|  | const Vec2 & | b )
| constexpr

Returns a minimum operation modifier for the given pair of vectors or elements.

On some architecture versions, this operation can be collapsed with a subsequent multiplication.

Parameters

  a | First vector or element passed to the operation. The type must meet aie::Vector or aie::Elem.
  b | Second vector or element passed to the operation. The type must be the same as for a.

## ◆ op_neg()

template<typename T>
requires (Vector<T> || Elem<T> || Accum<T> || is_op_v<T>)

binary_op< T, bool, Operation::Neg > aie::op_neg | ( | const T & | e,
|  | bool | to_negate )
| constexpr

Conditionally negates the operand based on the to_negate parameter.

On some architectures this operation can be collapsed with a subsequent operation.

Parameters

  e | Vector, element or accumulator passed to the operation. The type must meet aie::Vector, aie::Elem, aie::Accum or be another operation, using an integer type.
  to_negate | Controls if the first paramer is negated, or not.

## ◆ op_none() [1/2]

template<typename T>
requires (Vector<T> || SparseVector<T> || Elem<T> || Accum<T>)

unary_op< T, Operation::None > aie::op_none | ( | const T & | e | ) |
| constexpr

Returns an empty operation modifier for the given vector, vector element or accumulator.

Parameters

  e | Vector, vector element, or accumulator to which the operation is performed. The type must meet aie::Vector, aie::SparseVector, aie::Elem or aie::Accum.

## ◆ op_none() [2/2]

template<TensorBufferStream T>

unary_op< T, Operation::None > aie::op_none | ( | T & | e | ) |

Returns an empty operation modifier for the given tensor buffer stream.

Parameters

  e | A reference to a aie::TensorBufferStream

## ◆ op_or_none()

template<typename T>

auto aie::op_or_none | ( | T && | arg | ) |

Returns an empty operation modifier for the given input argument when it is not an operation already and when it is it returns the input itself.

Parameters

  arg | The input argument

## ◆ op_sign() [1/2]

template<typename T>
requires ((Vector<T> || SparseVector<T> || Elem<T> || Accum<T> || is_op_v<T>) && (!detail::is_complex_v<typename T::value_type>) && (!detail::is_floating_point_v<typename T::value_type>))

binary_op< T, bool, Operation::Sign > aie::op_sign | ( | const T & | e,
|  | bool | is_signed )
| constexpr

Returns dynamically signed/unsigned operation modifier for the vector or element, based on the boolean parameter.

On some architecture versions, this operation can be collapsed with a subsequent operation.

Parameters

  e | Vector, element or accumulator passed to the operation. The type must meet aie::Vector, aie::SparseVector, aie::Elem, aie::Accum or be another operation, using an integer type.
  is_signed | Controls if the first paramer is interpreted as signed, or not.

## ◆ op_sign() [2/2]

template<TensorBufferStream T>

binary_op< T, bool, Operation::Sign > aie::op_sign | ( | T & | e,
|  | bool | is_signed )

Returns dynamically signed/unsigned operation modifier for the given tensor buffer stream.

Parameters

  e | A reference to a aie::TensorBufferStream
  is_signed | Controls if the first paramer is interpreted as signed, or not.

## ◆ op_sub()

template<Accum Acc>

unary_op< Acc, Operation::Acc_Sub > aie::op_sub | ( | const Acc & | acc | ) |
| constexpr

Returns a subtraction operation modifier for the given accumulator.

Parameters

  acc | Accumulator to which the operation is performed.

## ◆ op_zero()

template<Accum Acc>

binary_op< Acc, bool, Operation::Zero > aie::op_zero | ( | const Acc & | acc,
|  | bool | to_zero )
| constexpr

Zeroes out the given accumulator or not depending on the zero parameter.

On some architectures this operation can be collapsed with a subsequent operation.

Parameters

  acc | Accumulator to which the operation is performed.
  to_zero | Controls if the passed accumulator is zeroed or not.