Skip to content

Commit 1524b7b

Browse files
committed
Merge branch 'dl_image_simd' into 'master'
Dl image simd See merge request ai/esp-dl!205
2 parents 037486b + 40f9fb1 commit 1524b7b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+11931
-561
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ sdkconfig
55
bin/
66
.idea/
77
__pycache__/
8+
.clangd
89

910
# unit test
1011
test_apps/*/*/build_*

.gitlab/ci/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ build_example_color_detect:
189189
- .rules:build:example_color_detect
190190
parallel:
191191
matrix:
192-
- IMAGE: [espressif/idf:release-v5.3, espressif/idf:latest]
192+
- IMAGE: [espressif/idf:release-v5.3, espressif/idf:release-v5.5]
193193
TARGET: [esp32p4, esp32s3]
194194
variables:
195195
EXAMPLE_DIR: examples/color_detect

esp-dl/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ set(include_dirs ./dl
2626
./fbs_loader/include
2727
./vision/detect
2828
./vision/image
29+
./vision/image/isa
2930
./vision/recognition
3031
./vision/classification
3132
./audio/common
@@ -49,6 +50,7 @@ elseif(CONFIG_IDF_TARGET_ESP32C3)
4950
elseif(CONFIG_IDF_TARGET_ESP32P4)
5051
list(APPEND src_dirs dl/tool/isa/esp32p4)
5152
list(APPEND src_dirs dl/base/isa/esp32p4)
53+
list(APPEND src_dirs ./vision/image/isa/esp32p4)
5254
endif()
5355

5456
set(requires dl_fft

esp-dl/dl/tool/include/dl_tool.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ typedef enum {
4343
} round_mode_t;
4444

4545
void dl_esp32p4_cfg_round(round_mode_t round_mode);
46-
int dl_esp32p4_round_half_even(float value);
46+
typedef enum { FORCE_ALIGN, HW_MISALIGN } misalign_mode_t;
47+
void dl_esp32p4_cfg_misalign(misalign_mode_t store, misalign_mode_t load);
48+
uint32_t dl_esp32p4_get_cfg();
4749
#endif
4850
}
4951

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
.text
2+
.global dl_esp32p4_cfg_round
3+
.type dl_esp32p4_cfg_round, @function
4+
.balign 4
5+
.option norvc
6+
dl_esp32p4_cfg_round:
7+
8+
# a0: int8_t round_mode
9+
# a1:
10+
# a2:
11+
12+
# a3:
13+
# a4:
14+
# a5:
15+
# t3:
16+
# t4:
17+
# t5:
18+
# t6:
19+
20+
# s0:
21+
# s1:
22+
# s8:
23+
# s9:
24+
# s10:
25+
# s11:
26+
27+
esp.movx.r.cfg a1
28+
li a2, 0xffffff0f
29+
and a1, a1, a2
30+
slli a0, a0, 4
31+
or a1, a1, a0
32+
esp.movx.w.cfg a1
33+
ret
34+
35+
36+
.align 2
37+
.text
38+
.global dl_esp32p4_cfg_misalign
39+
.type dl_esp32p4_cfg_misalign, @function
40+
dl_esp32p4_cfg_misalign:
41+
42+
# a0: bool store
43+
# a1: bool load
44+
45+
slli a1, a1, 1
46+
add a0, a0, a1
47+
esp.movx.r.cfg a1
48+
li a2, 0xfffffffc
49+
and a1, a1, a2
50+
or a1, a1, a0
51+
esp.movx.w.cfg a1
52+
ret
53+
54+
.align 2
55+
.text
56+
.global dl_esp32p4_get_cfg
57+
.type dl_esp32p4_get_cfg, @function
58+
dl_esp32p4_get_cfg:
59+
60+
# a0: uint32_t
61+
62+
esp.movx.r.cfg a0
63+
ret

esp-dl/dl/tool/isa/esp32p4/dl_esp32p4_round.S

Lines changed: 0 additions & 64 deletions
This file was deleted.

esp-dl/dl/tool/src/dl_tool.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ namespace tool {
2323
int round_half_even(float value)
2424
{
2525
#if CONFIG_ESP32P4_BOOST
26-
return dl_esp32p4_round_half_even(value);
26+
int ret;
27+
__asm__ volatile("fcvt.w.s %0, %1, rne" : "=r"(ret) : "f"(value));
28+
return ret;
2729
#else
2830
float rounded;
2931
if (value < 0) {

esp-dl/fbs_loader/cmake/data_file_embed_asm_aligned.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ append_line(".data")
7474
append_line("#if !defined (__APPLE__) && !defined (__linux__)")
7575
append_line(".section .rodata.embedded")
7676
append_line("#endif")
77-
append_line(".align 16")
77+
append_line(".balign 16")
7878
make_and_append_identifier("${varname}")
7979
make_and_append_identifier("_binary_${varname}_start" "for objcopy compatibility")
8080
append("${data}")

esp-dl/fbs_loader/src/fbs_loader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ FbsModel *create_fbs_model(const char *fbs_buf,
257257
fseek(f, 4, SEEK_CUR);
258258
}
259259
fread(model_buf, size, 1, f);
260+
fclose(f);
260261
}
261262

262263
assert(mode == 0 || mode == 1);

0 commit comments

Comments
 (0)