Vector Reduction - 2022.1 English

AI Engine Kernel Coding Best Practices Guide (UG1079)

Document ID
UG1079
Release Date
2022-05-25
Version
2022.1 English

AI Engine API supports vector reduce operations on aie::vector.

aie::reduce_add
Returns sum of the elements in the input vector.
aie::reduce_add_v
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.
aie::reduce_max
Returns the element from the input vector with the largest value.
aie::reduce_min
Returns the element from the input vector with the smallest value.
aie::reduce_mul
Returns multiplication of the elements in the input vector.

Vector reduction examples are as follows.

aie::vector<int16,8> iv=window_readincr_v<8>(data0);
aie::vector<int16,8> iv2,iv3,iv4;
int16 iv_add=aie::reduce_add(iv);
aie::vector<int16,8> iv_add_v4=aie::reduce_add_v(iv,iv2,iv3,iv4);
int16 iv_max=aie::reduce_max(iv);
int16 iv_min=aie::reduce_min(iv);
int16 iv_mul=aie::reduce_mul(iv);