ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
test_mmult.c
Go to the documentation of this file.
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4#include <math.h>
5
6#include "dsp_common.h"
7
8#include "dspm_mult.h"
11
12#define M 4
13#define N 8
14#define K 16
15
16const int m = M;
17const int n = N;
18const int k = K;
19
20float A[M][N];
21float B[N][K];
22float C[M][K];
23float C_compare[M][K];
24
26{
27
28 float *A_ptr = (float *)A;
29 float *B_ptr = (float *)B;
30 float *C_ptr = (float *)C;
31 float *Cc_ptr = (float *)C_compare;
32
33 for (int i = 0 ; i < m * n; i++) {
34 A_ptr[i] = i;
35 B_ptr[i] = i;
36 }
37 for (int i = 0 ; i < m ; i++) {
38 for (int j = 0 ; j < k ; j++) {
39 C_compare[i][j] = 0;
40 for (int s = 0 ; s < n ; s++) {
41 C_compare[i][j] += A[i][s] * B[s][j];
42 }
43 C[i][j] = -1;
44 }
45 }
47 dspm_mult_f32_ae32(A_ptr, B_ptr, Cc_ptr, m, n, k);
48 dspm_mult_f32_aes3(A_ptr, B_ptr, C_ptr, m, n, k);
50
51 for (int i = 0 ; i < m ; i++) {
52 for (int j = 0 ; j < k ; j++) {
53 printf("[%i][%i] calc=%f, expected =%f\n", i, j, C[i][j], C_compare[i][j]);
54 }
55 }
56 // Compare and check results
57 for (int i = 0 ; i < m * k ; i++) {
58 if (Cc_ptr[i] != C_ptr[i]) {
59 printf("Error - C_ptr= %f, Cc_ptr= %f \n", C_ptr[i], Cc_ptr[i]);
60 return;
61 }
62 }
63
64 printf("Test Pass!\n");
65}
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_ae32(const float *A, const float *B, float *C, int m, int n, int k)
#define N
Definition test_mmult.c:13
float C[4][16]
Definition test_mmult.c:22
void xt_iss_profile_disable()
const int m
Definition test_mmult.c:16
float B[8][16]
Definition test_mmult.c:21
float C_compare[4][16]
Definition test_mmult.c:23
void test_mmult()
Definition test_mmult.c:25
#define M
Definition test_mmult.c:12
float A[4][8]
Definition test_mmult.c:20
#define K
Definition test_mmult.c:14
const int n
Definition test_mmult.c:17
const int k
Definition test_mmult.c:18
void xt_iss_profile_enable()