ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
dspm_mult_ex_f32_ansi.c
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#include "dspm_mult.h"
8
9// Matrix A(m,n), m - amount or rows, n - amount of columns
10// C(m,k) = A(m,n)*B(n,k)
11// c(i * c_step,j) = sum(a(i * a_step,s)*b(s * b_step,j)) , s=1..n
12esp_err_t dspm_mult_ex_f32_ansi(const float *A, const float *B, float *C, int A_rows, int A_cols, int B_cols, int A_padding, int B_padding, int C_padding)
13{
14 if (NULL == A) {
16 }
17 if (NULL == B) {
19 }
20 if (NULL == C) {
22 }
23
24 if (A_rows <= 0) {
26 }
27 if (A_cols <= 0) {
29 }
30 if (B_cols <= 0) {
32 }
33
34 if (A_padding < 0) {
36 }
37 if (B_padding < 0) {
39 }
40 if (C_padding < 0) {
42 }
43
44 const int A_step = A_cols + A_padding;
45 const int B_step = B_cols + B_padding;
46 const int C_step = B_cols + C_padding;
47
48 for (int i = 0; i < A_rows; i++) {
49 for (int j = 0; j < B_cols; j++) {
50 C[i * C_step + j] = A[i * A_step] * B[j];
51 for (int s = 1; s < A_cols; s++) {
52 C[i * C_step + j] += A[i * A_step + s] * B[s * B_step + j];
53 }
54 }
55 }
56 return ESP_OK;
57}
#define ESP_ERR_DSP_PARAM_OUTOFRANGE
esp_err_t dspm_mult_ex_f32_ansi(const float *A, const float *B, float *C, int A_rows, int A_cols, int B_cols, int A_padding, int B_padding, int C_padding)
Matrix subset multiplication.
int esp_err_t
Definition esp_err.h:21
#define ESP_OK
Definition esp_err.h:23
float C[4][16]
Definition test_mmult.c:22
float B[8][16]
Definition test_mmult.c:21
float A[4][8]
Definition test_mmult.c:20