ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
dspm_mult_ex_f32_ansi.c File Reference
#include "dspm_mult.h"
Include dependency graph for dspm_mult_ex_f32_ansi.c:

Go to the source code of this file.

Functions

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.

Function Documentation

◆ dspm_mult_ex_f32_ansi()

esp_err_t dspm_mult_ex_f32_ansi ( const float * A,
const float * B,
float * C,
int m,
int n,
int k,
int A_padd,
int B_padd,
int C_padd )

Matrix subset multiplication.

One or all of the matrices are matrix subsets, described with pointers and strides Matrix multiplication for two floating point matrices: C[m][k] = A[m][n] * B[n][k] The extension (_ansi) use ANSI C and could be compiled and run on any platform. The extension (_ae32) is optimized for ESP32 chip.

Parameters
[in]Ainput matrix A[m][n]
[in]Binput matrix B[n][k]
[out]Cresult matrix C[m][k]
[in]mmatrix dimension
[in]nmatrix dimension
[in]kmatrix dimension
[in]A_paddinput matrix A padding
[in]B_paddinput matrix B padding
[in]C_paddresult matrix C padding
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 12 of file dspm_mult_ex_f32_ansi.c.

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
#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

References A, B, C, ESP_ERR_DSP_PARAM_OUTOFRANGE, and ESP_OK.