AI Engine architectures offer multiplication instructions that can perform additional operations on the input arguments. Instead of adding one variant for each possible combination, AI Engine 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 pre-multiplication operations are special empty operations that simply return the original objects they wrap. These include:
-
op_abs
-
op_add
-
op_conj
-
op_max
-
op_min
-
op_none
-
op_sub
aie::mul
and aie::mac
. They are not intended to be used
independently.The following example performs an element-wise multiplication of the absolute of vector a and the conjugate of vector b.
aie::accum<cacc48,16> foo(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;
}