AIfES 2
2.0.0
|
Go to the source code of this file.
Functions | |
void | aimath_q7_cmsis_linear32_bt (const aitensor_t *a, const aitensor_t *b, const aitensor_t *c, aitensor_t *result) |
Performs a matrix multiplication of Q7 matrices a and b (transposed) and adds a Q31 vector c to each row. More... | |
void aimath_q7_cmsis_linear32_bt | ( | const aitensor_t * | a, |
const aitensor_t * | b, | ||
const aitensor_t * | c, | ||
aitensor_t * | result | ||
) |
Performs a matrix multiplication of Q7 matrices a and b (transposed) and adds a Q31 vector c to each row.
The addition of the horizontal vector c is performed via broadcast, i.e. element wise in each column Mathematically this broadcast is equal to multiplying c with an vertical vector (with the same number of elements as c) and adding the result to \( a \cdot b^T \).
The quantization parameters of the vector c have to be {zero_point = 0, shift = a.shift + b.shift}!
\[ result = a \cdot b + \left( \begin{array}{c} 1 \\ 1 \\ \vdots \\ 1 \\ \end{array}\right) \cdot c \]
Example:
\[ a = \left( \begin{array}{rrr} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \end{array}\right) \]
\[ b = \left( \begin{array}{rr} 1 & 0 & 0 \\ 0 & 1 & 0 \end{array}\right) \]
\[ c = \left( \begin{array}{rr} 2 & 5 \end{array}\right) \]
\[ result = a \cdot b^T + \left( \begin{array}{r} 1 \\ 1 \\ 1 \\ \end{array}\right) \cdot c \]
\[ = \left( \begin{array}{rr} 1 & 2 \\ 4 & 5 \\ 7 & 8 \end{array}\right) + \left( \begin{array}{rr} 2 & 5 \\ 2 & 5 \\ 2 & 5 \end{array}\right) \]
\[ = \left( \begin{array}{rr} 3 & 7 \\ 6 & 10 \\ 9 & 13 \end{array}\right) \]
Example:
*a | Q7 matrix a (2D tensor of shape [N x K]) |
*b | Q7 matrix b (2D tensor of shape [M x K]) |
*c | Q31 vector c (2D tensor of shape [1 x M] or 1D tensor of shape [M]) |
*result | Resulting Q7 matrix (2D tensor of shape [N x M]) |