accumulate - 2024.1 English

AI Engine-ML Kernel and Graph Programming Guide (UG1603)

Document ID
Release Date
2024.1 English

AI Engine API supports accumulating variable number of vectors multiplied by coefficients – aie::accumulate. Following picture shows an example of weighted accumulation on four vectors:

Figure 1. Vector Arithmetic Operations

The following code shows an example of aie::accumulate:

/*template<unsigned Lanes, AccumOrOp Acc, Vector VecCoeff, Vector VecData, Vector... NextVecData>
aie::accumulate(const Acc & acc,
    const VecCoeff & coeff,
    unsigned coeff_start,
    const VecData & data,
    const NextVecData &... next_data)
aie::vector<int16,16> coe;
aie::vector<int16,16> vdata,vnext1,vnext2,vnext3,vnext4;
auto acc=aie::accumulate<16>(coe,2,vdata,vnext1,vnext2,vnext3);//coeff_start=2
Note: All data vectors should have the same type and size.