ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
dspm_add_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
8#include "dspm_add.h"
9
10esp_err_t dspm_add_f32_ansi(const float *input1, const float *input2, float *output, int rows, int cols, int padd1, int padd2, int padd_out, int step1, int step2, int step_out)
11{
12 if (NULL == input1) {
14 }
15 if (NULL == input2) {
17 }
18 if (NULL == output) {
20 }
21
22 if (rows <= 0) {
24 }
25 if (cols <= 0) {
27 }
28
29 if (padd1 < 0) {
31 }
32 if (padd2 < 0) {
34 }
35 if (padd_out < 0) {
37 }
38
39 if (step1 <= 0) {
41 }
42 if (step2 <= 0) {
44 }
45 if (step_out <= 0) {
47 }
48
49 const int ptr_input1_step = cols + padd1;
50 const int ptr_input2_step = cols + padd2;
51 const int ptr_output_step = cols + padd_out;
52 float *ptr_input1 = (float *)input1;
53 float *ptr_input2 = (float *)input2;
54
55 for (int row = 0; row < rows; row++) {
56 for (int col = 0; col < cols; col++) {
57 output[col * step_out] = ptr_input1[col * step1] + ptr_input2[col * step2];
58 }
59 ptr_input1 += ptr_input1_step;
60 ptr_input2 += ptr_input2_step;
61 output += ptr_output_step;
62 }
63 return ESP_OK;
64}
#define ESP_ERR_DSP_PARAM_OUTOFRANGE
esp_err_t dspm_add_f32_ansi(const float *input1, const float *input2, float *output, int rows, int cols, int padd1, int padd2, int padd_out, int step1, int step2, int step_out)
add two arrays with paddings (add two sub-matrices)
int esp_err_t
Definition esp_err.h:21
#define ESP_OK
Definition esp_err.h:23