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

Loading...
Searching...
No Matches
Functions
Reduction

## Overview

Vector reduction operations.

## Functions
template<ElemBaseType T, Accum Acc> requires (Acc::value_class() == detail::accum_class_for_type_v<T>)
T | aie::reduce_add (const Acc &acc)
| Returns the sum of all input vector elements.
template<Vector Vec>
Vec::value_type | aie::reduce_add (const Vec &v)
| Returns the sum of all input vector elements.
template<RealVector Vec>
Vec::value_type | aie::reduce_max (const Vec &v)
| Returns the element from the input vector with the largest value.
template<RealVector Vec>
Vec::value_type | aie::reduce_min (const Vec &v)
| Returns the element from the input vector with the smallest value.
template<Vector Vec>
constexpr Vec::value_type | aie::reduce_mul (const Vec &v)
| Returns a product of the elements in the input vector.

## Function Documentation

## ◆ reduce_add() [1/2]

template<ElemBaseType T, Accum Acc>
requires (Acc::value_class() == detail::accum_class_for_type_v<T>)

T aie::reduce_add | ( | const Acc & | acc | ) |

Returns the sum of all input vector elements.

This overload is useful when the result must be converted to a lower precision format and the input values are already available in an accumulator (for example, as a result of a previous operation such as a multiplication).

Parameters

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

Template Parameters

  Acc | Input accumulator type.
  T | Result type after reduction. The type must be compatible with the input accumulator.

Example:

aie::accum<accfloat, 16> acc = ...;
bfloat16 result = aie::reduce_add<bfloat16>(acc);
aie::accum
Type for vector accumulators.
Definition accum.hpp:49
aie::reduce_add
Vec::value_type reduce_add(const Vec &v)
Returns the sum of all input vector elements.
Definition aie.hpp:4220
bfloat16
Definition types.hpp:88

## ◆ reduce_add() [2/2]

template<Vector Vec>

Vec::value_type aie::reduce_add | ( | const Vec & | v | ) |

Returns the sum of all input vector elements.

Higher precision intermediate values may be used to perform this reduction.

Parameters

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

## ◆ reduce_max()

template<RealVector Vec>

Vec::value_type aie::reduce_max | ( | const Vec & | v | ) |

Returns the element from the input vector with the largest value.

Parameters

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

## ◆ reduce_min()

template<RealVector Vec>

Vec::value_type aie::reduce_min | ( | const Vec & | v | ) |

Returns the element from the input vector with the smallest value.

Parameters

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

## ◆ reduce_mul()

template<Vector Vec>

Vec::value_type aie::reduce_mul | ( | const Vec & | v | ) |
| constexpr

Returns a product of the elements in the input vector.

Parameters

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