ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
dspm_mult.h File Reference
#include "dsp_err.h"
#include "dspm_mult_platform.h"
Include dependency graph for dspm_mult.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

esp_err_t dspm_mult_3x3x1_f32_ae32 (const float *A, const float *B, float *C)
 Matrix multiplication A[3x3]xB[3x1].
esp_err_t dspm_mult_3x3x3_f32_ae32 (const float *A, const float *B, float *C)
 Matrix multiplication A[3x3]xB[3x3].
esp_err_t dspm_mult_4x4x1_f32_ae32 (const float *A, const float *B, float *C)
 Matrix multiplication A[4x4]xB[4x1].
esp_err_t dspm_mult_4x4x4_f32_ae32 (const float *A, const float *B, float *C)
 Matrix multiplication A[4x4]xB[4x4].
esp_err_t dspm_mult_f32_ansi (const float *A, const float *B, float *C, int m, int n, int k)
 Matrix multiplication.
esp_err_t dspm_mult_f32_ae32 (const float *A, const float *B, float *C, int m, int n, int k)
esp_err_t dspm_mult_f32_aes3 (const float *A, const float *B, float *C, int m, int n, int k)
esp_err_t dspm_mult_f32_arp4 (const float *A, const float *B, float *C, int m, int n, int k)
esp_err_t dspm_mult_s16_ansi (const int16_t *A, const int16_t *B, int16_t *C, int m, int n, int k, int shift)
 Matrix multiplication 16 bit signeg int.
esp_err_t dspm_mult_s16_ae32 (const int16_t *A, const int16_t *B, int16_t *C, int m, int n, int k, int shift)
esp_err_t dspm_mult_s16_aes3 (const int16_t *A, const int16_t *B, int16_t *C, int m, int n, int k, int shift)
esp_err_t dspm_mult_s16_arp4 (const int16_t *A, const int16_t *B, int16_t *C, int m, int n, int k, int shift)
#define dspm_mult_s16   dspm_mult_s16_ansi
#define dspm_mult_f32   dspm_mult_f32_ansi
#define dspm_mult_3x3x1_f32(A, B, C)
#define dsps_sub_f32   dsps_sub_f32_ansi
#define dsps_add_f32   dsps_add_f32_ansi
#define dspm_mult_4x4x4_f32(A, B, C)
#define dspm_mult_ex_f32   dspm_mult_ex_f32_ansi
#define dspm_mult_3x3x3_f32(A, B, C)
#define dspm_mult_4x4x1_f32(A, B, C)
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.
esp_err_t dspm_mult_ex_f32_ae32 (const float *A, const float *B, float *C, int m, int n, int k, int A_padd, int B_padd, int C_padd)
esp_err_t dspm_mult_ex_f32_aes3 (const float *A, const float *B, float *C, int m, int n, int k, int A_padd, int B_padd, int C_padd)
esp_err_t dspm_mult_ex_f32_arp4 (const float *A, const float *B, float *C, int m, int n, int k, int A_padd, int B_padd, int C_padd)

Macro Definition Documentation

◆ dspm_mult_3x3x1_f32

#define dspm_mult_3x3x1_f32 ( A,
B,
C )
Value:
dspm_mult_f32(A,B,C, 3, 3, 1)
#define dspm_mult_f32
Definition dspm_mult.h:221
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

Definition at line 222 of file dspm_mult.h.

◆ dspm_mult_3x3x3_f32

#define dspm_mult_3x3x3_f32 ( A,
B,
C )
Value:
dspm_mult_f32(A,B,C,3,3,3);

Definition at line 227 of file dspm_mult.h.

◆ dspm_mult_4x4x1_f32

#define dspm_mult_4x4x1_f32 ( A,
B,
C )
Value:
dspm_mult_f32(A,B,C, 4, 4, 1)

Definition at line 228 of file dspm_mult.h.

◆ dspm_mult_4x4x4_f32

#define dspm_mult_4x4x4_f32 ( A,
B,
C )
Value:
dspm_mult_f32(A,B,C, 4, 4, 4)

Definition at line 225 of file dspm_mult.h.

◆ dspm_mult_ex_f32

#define dspm_mult_ex_f32   dspm_mult_ex_f32_ansi

Definition at line 226 of file dspm_mult.h.

Referenced by dspm::operator*(), and dspm::Mat::operator*=().

◆ dspm_mult_f32

#define dspm_mult_f32   dspm_mult_f32_ansi

Definition at line 221 of file dspm_mult.h.

Referenced by dspm::operator*(), and dspm::Mat::operator*=().

◆ dspm_mult_s16

#define dspm_mult_s16   dspm_mult_s16_ansi

Definition at line 220 of file dspm_mult.h.

◆ dsps_add_f32

#define dsps_add_f32   dsps_add_f32_ansi

Definition at line 224 of file dspm_mult.h.

◆ dsps_sub_f32

#define dsps_sub_f32   dsps_sub_f32_ansi

Definition at line 223 of file dspm_mult.h.

Function Documentation

◆ dspm_mult_3x3x1_f32_ae32()

esp_err_t dspm_mult_3x3x1_f32_ae32 ( const float * A,
const float * B,
float * C )

Matrix multiplication A[3x3]xB[3x1].

Matrix multiplication for two floating point matrices 3x3 and 3x1: C[1][3] = A[3][3] * B[3][1] The implementation is optimized for ESP32 chip.

Parameters
[in]Ainput matrix A[3][3]
[in]Binput matrix/vector B[3][1]
Cresult matrix/vector C[3][3]
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

References A, B, and C.

◆ dspm_mult_3x3x3_f32_ae32()

esp_err_t dspm_mult_3x3x3_f32_ae32 ( const float * A,
const float * B,
float * C )

Matrix multiplication A[3x3]xB[3x3].

Matrix multiplication for two square 3x3 floating point matrices: C[3][3] = A[3][3] * B[3][3] The implementation is optimized for ESP32 chip.

Parameters
[in]Ainput matrix A[3][3]
[in]Binput matrix B[3][3]
Cresult matrix C[3][3]
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

References A, B, and C.

◆ dspm_mult_4x4x1_f32_ae32()

esp_err_t dspm_mult_4x4x1_f32_ae32 ( const float * A,
const float * B,
float * C )

Matrix multiplication A[4x4]xB[4x1].

Matrix multiplication for two floating point matrices 4x4 and 4x1: C[1][4] = A[4][4] * B[4][1] The implementation is optimized for ESP32 chip.

Parameters
[in]Ainput matrix A[4][4]
[in]Binput matrix/vector B[4][1]
Cresult matrix/vector C[4][4]
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

References A, B, and C.

◆ dspm_mult_4x4x4_f32_ae32()

esp_err_t dspm_mult_4x4x4_f32_ae32 ( const float * A,
const float * B,
float * C )

Matrix multiplication A[4x4]xB[4x4].

Matrix multiplication for two square 3x3 floating point matrices: C[4][4] = A[4][4] * B[4][4] The implementation is optimized for ESP32 chip.

Parameters
[in]Ainput matrix A[4][4]
[in]Binput matrix B[4][4]
Cresult matrix C[4][4]
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

References A, B, C, k, m, and n.

◆ dspm_mult_ex_f32_ae32()

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

References A, B, C, k, m, and n.

◆ dspm_mult_ex_f32_aes3()

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

References A, B, C, k, m, and n.

◆ 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

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

◆ dspm_mult_ex_f32_arp4()

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

References A, B, C, k, m, and n.

◆ dspm_mult_f32_ae32()

esp_err_t dspm_mult_f32_ae32 ( const float * A,
const float * B,
float * C,
int m,
int n,
int k )

References A, B, C, k, m, and n.

Referenced by test_mmult().

Here is the caller graph for this function:

◆ dspm_mult_f32_aes3()

esp_err_t dspm_mult_f32_aes3 ( const float * A,
const float * B,
float * C,
int m,
int n,
int k )

References A, B, C, k, m, and n.

Referenced by test_mmult().

Here is the caller graph for this function:

◆ dspm_mult_f32_ansi()

esp_err_t dspm_mult_f32_ansi ( const float * A,
const float * B,
float * C,
int m,
int n,
int k )

Matrix multiplication.

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]
Cresult matrix C[m][k]
[in]mmatrix dimension
[in]nmatrix dimension
[in]kmatrix dimension
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 22 of file dspm_mult_f32_ansi.c.

23{
24 for (int i = 0 ; i < m ; i++) {
25 for (int j = 0 ; j < k ; j++) {
26 C[i * k + j] = A[i * n] * B[j];
27 for (int s = 1; s < n ; s++) {
28 C[i * k + j] += A[i * n + s] * B[s * k + j];
29 }
30 }
31 }
32 return ESP_OK;
33}
const int m
Definition test_mmult.c:16
const int n
Definition test_mmult.c:17
const int k
Definition test_mmult.c:18

References A, B, C, ESP_OK, k, m, and n.

◆ dspm_mult_f32_arp4()

esp_err_t dspm_mult_f32_arp4 ( const float * A,
const float * B,
float * C,
int m,
int n,
int k )

References A, B, C, k, m, and n.

◆ dspm_mult_s16_ae32()

esp_err_t dspm_mult_s16_ae32 ( const int16_t * A,
const int16_t * B,
int16_t * C,
int m,
int n,
int k,
int shift )

References A, B, C, k, m, and n.

◆ dspm_mult_s16_aes3()

esp_err_t dspm_mult_s16_aes3 ( const int16_t * A,
const int16_t * B,
int16_t * C,
int m,
int n,
int k,
int shift )

References A, B, C, k, m, and n.

◆ dspm_mult_s16_ansi()

esp_err_t dspm_mult_s16_ansi ( const int16_t * A,
const int16_t * B,
int16_t * C,
int m,
int n,
int k,
int shift )

Matrix multiplication 16 bit signeg int.

Matrix multiplication for two signed 16 bit fixed point matrices: C[m][k] = (A[m][n] * B[n][k]) >> (15- shift) 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]
Cresult matrix C[m][k]
[in]mmatrix dimension
[in]nmatrix dimension
[in]kmatrix dimension
[in]shiftevery result will be shifted and stored as 16 bit signed value.
Returns
  • ESP_OK on success
  • One of the error codes from DSP library

Definition at line 21 of file dspm_mult_s16_ansi.c.

22{
23 int final_shift = shift - 15;
24 for (int i = 0 ; i < m ; i++) {
25 for (int j = 0 ; j < k ; j++) {
26 // This code also could be used
27 //dsps_dotprode_f32_ae32(&A[i*n],&B[j],&C[i*k + j],n,1,n);
28 long long acc = 0x7fff >> shift;
29 for (int s = 0; s < n ; s++) {
30 acc += (int32_t)A[i * n + s] * (int32_t)B[s * k + j];
31 }
32 if (final_shift > 0) {
33 C[i * k + j] = (acc << final_shift);
34 } else {
35 C[i * k + j] = (acc >> (-final_shift));
36 }
37 }
38 }
39 return ESP_OK;
40}

References A, B, C, ESP_OK, k, m, and n.

◆ dspm_mult_s16_arp4()

esp_err_t dspm_mult_s16_arp4 ( const int16_t * A,
const int16_t * B,
int16_t * C,
int m,
int n,
int k,
int shift )

References A, B, C, k, m, and n.