add some code

This commit is contained in:
2025-09-05 13:25:11 +08:00
parent 9ff0a99e7a
commit 3cf1229a85
8911 changed files with 2535396 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "dspm_addc_platform.h"
#if (dspm_addc_f32_ae32_enabled == 1)
// This is an add function for sub-matrices for ESP32 processor
.text
.align 4
.global dspm_addc_f32_ae32
.type dspm_addc_f32_ae32,@function
// The function implements the following C code:
// esp_err_t dspm_addc_f32_ansi(const float *input, float *output, float C, int rows, int cols, int padd_in, int padd_out, int step_in, int step_out);
dspm_addc_f32_ae32:
// input - a2
// output - a3
// C - a4
// rows - a5
// cols - a6
// padd_in - a7
// padd_out - a8
// step_in - a9
// step_out - a10
entry a1, 16
l32i.n a8, a1, 16 // padd_out
l32i.n a9, a1, 20 // step_in
l32i.n a10, a1, 24 // step_out
slli a9, a9, 2 // a9 - step_in << 2
slli a10, a10, 2 // a10 - step_out << 2
wfr f0, a4 // a4 - load to the f0
.outer_loop_addc_f32_ae32:
loopnez a6, .loop_addc_f32_ae32
lsxp f1, a2, a9 // load input to f1, increment input (input_ptr+=step_in)
add.s f2, f0, f1 // f2 = f0 + f1
ssxp f2, a3, a10 // save result f2 to output a3, increment output (output_ptr+=step_out)
.loop_addc_f32_ae32:
addx4 a2, a7, a2 // input1_ptr += (padd_in << 2);
addx4 a3, a8, a3 // output_ptr += (padd_out << 2);
addi.n a5, a5, -1 // rows - 1
bnez a5, .outer_loop_addc_f32_ae32
movi.n a2, 0 // return status ESP_OK
retw.n
#endif // dspm_add_f32_ae32_enabled

View File

@@ -0,0 +1,51 @@
/*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "dspm_addc.h"
esp_err_t dspm_addc_f32_ansi(const float *input, float *output, float C, int rows, int cols, int padd_in, int padd_out, int step_in, int step_out)
{
if (NULL == input) {
return ESP_ERR_DSP_PARAM_OUTOFRANGE;
}
if (NULL == output) {
return ESP_ERR_DSP_PARAM_OUTOFRANGE;
}
if (rows <= 0) {
return ESP_ERR_DSP_PARAM_OUTOFRANGE;
}
if (cols <= 0) {
return ESP_ERR_DSP_PARAM_OUTOFRANGE;
}
if (padd_in < 0) {
return ESP_ERR_DSP_PARAM_OUTOFRANGE;
}
if (padd_out < 0) {
return ESP_ERR_DSP_PARAM_OUTOFRANGE;
}
if (step_in <= 0) {
return ESP_ERR_DSP_PARAM_OUTOFRANGE;
}
if (step_out <= 0) {
return ESP_ERR_DSP_PARAM_OUTOFRANGE;
}
const int ptr_step_in = cols + padd_in;
const int ptr_step_out = cols + padd_out;
float *ptr_input = (float *)input;
for (int row = 0; row < rows; row++) {
for (int col = 0; col < cols; col++) {
output[col * step_out] = ptr_input[col * step_in] + C;
}
output += ptr_step_out;
ptr_input += ptr_step_in;
}
return ESP_OK;
}