| 167 | |
| 168 | template <typename T> |
| 169 | void matrix_multiply(const SimpleTensor<T> &a, const SimpleTensor<T> &b, SimpleTensor<T> &out) |
| 170 | { |
| 171 | ARM_COMPUTE_ERROR_ON(a.shape()[0] != b.shape()[1]); |
| 172 | ARM_COMPUTE_ERROR_ON(a.shape()[1] != out.shape()[1]); |
| 173 | ARM_COMPUTE_ERROR_ON(b.shape()[0] != out.shape()[0]); |
| 174 | |
| 175 | const int M = a.shape()[1]; // Rows |
| 176 | const int N = b.shape()[0]; // Cols |
| 177 | const int K = b.shape()[1]; |
| 178 | |
| 179 | #if defined(_OPENMP) |
| 180 | #pragma omp parallel for collapse(2) |
| 181 | #endif /* _OPENMP */ |
| 182 | for (int y = 0; y < M; ++y) |
| 183 | { |
| 184 | for (int x = 0; x < N; ++x) |
| 185 | { |
| 186 | float acc = 0.0f; |
| 187 | for (int k = 0; k < K; ++k) |
| 188 | { |
| 189 | acc += a[y * K + k] * b[x + k * N]; |
| 190 | } |
| 191 | |
| 192 | out[x + y * N] = acc; |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | template <typename T> |
| 198 | void transpose_matrix(const SimpleTensor<T> &in, SimpleTensor<T> &out) |