Skip to content

Commit 8fad999

Browse files
authored
Arm backend: Enable building for Corstone-300_U65 (pytorch#20067)
Tested with two tests in test_arm_backend.sh
1 parent 07b8c20 commit 8fad999

5 files changed

Lines changed: 113 additions & 9 deletions

File tree

backends/arm/scripts/corstone_utils.cmake

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function(fetch_ethos_u_content ETHOS_SDK_PATH ET_DIR_PATH)
7979
endfunction()
8080

8181
function(add_corstone_subdirectory SYSTEM_CONFIG ETHOS_SDK_PATH)
82-
if(SYSTEM_CONFIG MATCHES "Ethos_U55")
82+
if(SYSTEM_CONFIG MATCHES "Ethos_U55" OR SYSTEM_CONFIG MATCHES "Ethos_U65")
8383
add_subdirectory(
8484
${ETHOS_SDK_PATH}/core_platform/targets/corstone-300 target
8585
)
@@ -101,7 +101,7 @@ function(add_corstone_subdirectory SYSTEM_CONFIG ETHOS_SDK_PATH)
101101
else()
102102
message(
103103
FATAL_ERROR
104-
"Unsupported MEMORY_MODE ${MEMORY_MODE}. Memory_mode can be Shared_Sram, Sram_Only or Dedicated_Sram(applicable for the Ethos-U85)"
104+
"Unsupported MEMORY_MODE ${MEMORY_MODE}. Memory_mode can be Shared_Sram, Sram_Only or Dedicated_Sram(applicable for the Ethos-U65 and Ethos-U85)"
105105
)
106106
endif()
107107
endfunction()
@@ -268,6 +268,85 @@ function(configure_timing_adapters SYSTEM_CONFIG MEMORY_MODE)
268268
"Unsupported memory_mode ${MEMORY_MODE} for the Ethos-U55. The Ethos-U55 supports only Shared_Sram and Sram_Only."
269269
)
270270
endif()
271+
elseif(SYSTEM_CONFIG STREQUAL "Ethos_U65_High_End")
272+
set(TARGET_BOARD
273+
"corstone-300"
274+
PARENT_SCOPE
275+
)
276+
if(MEMORY_MODE MATCHES "Shared_Sram")
277+
target_compile_definitions(
278+
ethosu_target_common
279+
INTERFACE # Configure NPU architecture timing adapters This is just
280+
# example numbers and you should make this match your hardware
281+
# SRAM
282+
ETHOSU_TA_MAXR_0=16
283+
ETHOSU_TA_MAXW_0=16
284+
ETHOSU_TA_MAXRW_0=0
285+
ETHOSU_TA_RLATENCY_0=32
286+
ETHOSU_TA_WLATENCY_0=32
287+
ETHOSU_TA_PULSE_ON_0=15999
288+
ETHOSU_TA_PULSE_OFF_0=1
289+
ETHOSU_TA_BWCAP_0=16000
290+
ETHOSU_TA_PERFCTRL_0=0
291+
ETHOSU_TA_PERFCNT_0=0
292+
ETHOSU_TA_MODE_0=1
293+
ETHOSU_TA_HISTBIN_0=0
294+
ETHOSU_TA_HISTCNT_0=0
295+
# DRAM
296+
ETHOSU_TA_MAXR_1=24
297+
ETHOSU_TA_MAXW_1=12
298+
ETHOSU_TA_MAXRW_1=0
299+
ETHOSU_TA_RLATENCY_1=500
300+
ETHOSU_TA_WLATENCY_1=250
301+
ETHOSU_TA_PULSE_ON_1=4000
302+
ETHOSU_TA_PULSE_OFF_1=1000
303+
ETHOSU_TA_BWCAP_1=3750
304+
ETHOSU_TA_PERFCTRL_1=0
305+
ETHOSU_TA_PERFCNT_1=0
306+
ETHOSU_TA_MODE_1=1
307+
ETHOSU_TA_HISTBIN_1=0
308+
ETHOSU_TA_HISTCNT_1=0
309+
)
310+
elseif(MEMORY_MODE MATCHES "Sram_Only")
311+
target_compile_definitions(
312+
ethosu_target_common
313+
INTERFACE # Configure NPU architecture timing adapters This is just
314+
# example numbers and you should make this match your hardware
315+
# SRAM
316+
ETHOSU_TA_MAXR_0=16
317+
ETHOSU_TA_MAXW_0=16
318+
ETHOSU_TA_MAXRW_0=0
319+
ETHOSU_TA_RLATENCY_0=32
320+
ETHOSU_TA_WLATENCY_0=32
321+
ETHOSU_TA_PULSE_ON_0=15999
322+
ETHOSU_TA_PULSE_OFF_0=1
323+
ETHOSU_TA_BWCAP_0=16000
324+
ETHOSU_TA_PERFCTRL_0=0
325+
ETHOSU_TA_PERFCNT_0=0
326+
ETHOSU_TA_MODE_0=1
327+
ETHOSU_TA_HISTBIN_0=0
328+
ETHOSU_TA_HISTCNT_0=0
329+
# Set the second Timing Adapter to SRAM latency & bandwidth
330+
ETHOSU_TA_MAXR_1=16
331+
ETHOSU_TA_MAXW_1=16
332+
ETHOSU_TA_MAXRW_1=0
333+
ETHOSU_TA_RLATENCY_1=32
334+
ETHOSU_TA_WLATENCY_1=32
335+
ETHOSU_TA_PULSE_ON_1=15999
336+
ETHOSU_TA_PULSE_OFF_1=1
337+
ETHOSU_TA_BWCAP_1=16000
338+
ETHOSU_TA_PERFCTRL_1=0
339+
ETHOSU_TA_PERFCNT_1=0
340+
ETHOSU_TA_MODE_1=1
341+
ETHOSU_TA_HISTBIN_1=0
342+
ETHOSU_TA_HISTCNT_1=0
343+
)
344+
else()
345+
message(
346+
FATAL_ERROR
347+
"Unsupported memory_mode ${MEMORY_MODE} for the Ethos-U65. The Ethos-U65 supports Shared_Sram and Sram_Only in this runner."
348+
)
349+
endif()
271350
elseif(SYSTEM_CONFIG MATCHES "Ethos_U85_SYS_DRAM_Low")
272351
add_subdirectory(
273352
${ETHOS_SDK_PATH}/core_platform/targets/corstone-320 target

backends/arm/scripts/run_fvp.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ elf_file=$(realpath ${elf_file})
5959
# the Corstone-300 M55 (ISA superset).
6060
if [[ ${target} == *"ethos-u55"* || ${target} == cortex-m* && ${target} != cortex-m85* ]]; then
6161
fvp_model=FVP_Corstone_SSE-300_Ethos-U55
62+
elif [[ ${target} == *"ethos-u65"* ]]; then
63+
fvp_model=FVP_Corstone_SSE-300_Ethos-U65
6264
else
6365
fvp_model=FVP_Corstone_SSE-320
6466
fi
@@ -144,7 +146,7 @@ if [[ ${target} == cortex-m* ]]; then
144146
rm "${log_file}"
145147
exit 1
146148
fi
147-
elif [[ ${target} == *"ethos-u55"* ]]; then
149+
elif [[ ${target} == *"ethos-u55"* || ${target} == *"ethos-u65"* ]]; then
148150
${nobuf} ${fvp_model} \
149151
-C ethosu.num_macs=${num_macs} \
150152
-C mps3_board.visualisation.disable-visualisation=1 \

backends/arm/test/test_arm_backend.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ test_run_ethos_u55() {
167167
examples/arm/run.sh --et_build_root=arm_test/test_run --target=ethos-u55-128 --model_name=examples/arm/example_modules/add.py
168168
examples/arm/run.sh --et_build_root=arm_test/test_run --target=ethos-u55-128 --model_name=examples/arm/example_modules/add.py --bundleio
169169

170+
echo "${TEST_SUITE_NAME}: Test target Ethos-U65"
171+
examples/arm/run.sh --et_build_root=arm_test/test_run --target=ethos-u65-256 --model_name=examples/arm/example_modules/add.py
172+
examples/arm/run.sh --et_build_root=arm_test/test_run --target=ethos-u65-256 --model_name=examples/arm/example_modules/add.py --bundleio
173+
170174
# Cortex-M op tests
171175
echo "${TEST_SUITE_NAME}: Test target Cortex-M55 (on Ethos-U55)"
172176
examples/arm/run.sh --et_build_root=arm_test/test_run --target=ethos-u55-128 --model_name=add --bundleio --no_delegate --select_ops_list="aten::add.out"

examples/arm/executor_runner/CMakeLists.txt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,14 +249,20 @@ target_sources(
249249
# Check for "U55" in SYSTEM_CONFIG
250250
string(FIND "${SYSTEM_CONFIG}" "U55" U55_FOUND)
251251

252+
# Check for "U65" in SYSTEM_CONFIG
253+
string(FIND "${SYSTEM_CONFIG}" "U65" U65_FOUND)
254+
252255
# Check for "U85" in SYSTEM_CONFIG
253256
string(FIND "${SYSTEM_CONFIG}" "U85" U85_FOUND)
254257

255-
# Check if neither "U55" nor "U85" was found
256-
if(U55_FOUND EQUAL -1 AND U85_FOUND EQUAL -1)
258+
# Check if neither "U55", "U65" nor "U85" was found
259+
if(U55_FOUND EQUAL -1
260+
AND U65_FOUND EQUAL -1
261+
AND U85_FOUND EQUAL -1
262+
)
257263
message(
258264
FATAL_ERROR
259-
"SYSTEM_CONFIG does not contain 'U55' or 'U85'. Configuration aborting."
265+
"SYSTEM_CONFIG does not contain 'U55', 'U65' or 'U85'. Configuration aborting."
260266
)
261267
endif()
262268

@@ -266,6 +272,11 @@ if(NOT U55_FOUND EQUAL -1)
266272
set(LINK_FILE_IN "${CMAKE_CURRENT_LIST_DIR}/Corstone-300.ld")
267273
endif()
268274

275+
if(NOT U65_FOUND EQUAL -1)
276+
message(STATUS "SYSTEM_CONFIG contains 'U65'.")
277+
set(LINK_FILE_IN "${CMAKE_CURRENT_LIST_DIR}/Corstone-300.ld")
278+
endif()
279+
269280
if(NOT U85_FOUND EQUAL -1)
270281
message(STATUS "SYSTEM_CONFIG contains 'U85'.")
271282
set(LINK_FILE_IN "${CMAKE_CURRENT_LIST_DIR}/Corstone-320.ld")

examples/arm/run.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ function help() {
7777
echo " --build_only Only build, don't run"
7878
echo " --extra_build_flags=\"<FLAGS>\" Extra -D style flags to pass to cmake when run.sh auto-configures the build"
7979
echo " --toolchain=<arm-none-eabi-gcc|arm-zephyr-eabi-gcc> Toolchain preset to use when run.sh auto-configures the build. Default: ${toolchain}"
80-
echo " --system_config=<CONFIG> Ethos-U: System configuration to select from the Vela configuration file (see vela.ini). Default: Ethos_U55_High_End_Embedded for EthosU55 targets, Ethos_U85_SYS_DRAM_Mid for EthosU85 targets."
80+
echo " --system_config=<CONFIG> Ethos-U: System configuration to select from the Vela configuration file (see vela.ini). Default: Ethos_U55_High_End_Embedded for EthosU55 targets, Ethos_U65_High_End for EthosU65 targets, Ethos_U85_SYS_DRAM_Mid for EthosU85 targets."
8181
echo " NOTE: If given, this option must match the given target. This option also sets timing adapter values customized for specific hardware, see ./executor_runner/CMakeLists.txt."
8282
echo " --config=<FILEPATH> Ethos-U: System configuration file that specifies system configurations (vela.ini)"
83-
echo " --memory_mode=<MODE> Ethos-U: Memory mode to select from the Vela configuration file (see vela.ini), e.g. Shared_Sram/Sram_Only. Default: 'Shared_Sram' for Ethos-U55 targets, 'Sram_Only' for Ethos-U85 targets"
83+
echo " --memory_mode=<MODE> Ethos-U: Memory mode to select from the Vela configuration file (see vela.ini), e.g. Shared_Sram/Sram_Only. Default: 'Shared_Sram' for Ethos-U55 targets, 'Sram_Only' for Ethos-U65 targets and 'Dedicated_Sram_384KB' for Ethos-U85 targets"
8484
echo " --pte_placement=<elf|ADDR> Ethos-U: Control if runtime has PTE baked into the elf or if its placed in memory outside of the elf, defaults to ${pte_placement}"
8585
echo " --specify_ethosu_scratch Use actual Ethos-U scratch size for given model to size temp allocator"
8686
echo " --et_build_root=<FOLDER> Executorch build output root folder to use, defaults to ${et_build_root}"
@@ -187,6 +187,10 @@ esac
187187
if [[ ${system_config} == "" ]]
188188
then
189189
system_config="Ethos_U55_High_End_Embedded"
190+
if [[ ${target} =~ "ethos-u65" ]]
191+
then
192+
system_config="Ethos_U65_High_End"
193+
fi
190194
if [[ ${target} =~ "ethos-u85" ]]
191195
then
192196
system_config="Ethos_U85_SYS_DRAM_Mid"
@@ -196,6 +200,10 @@ fi
196200
if [[ ${memory_mode} == "" ]]
197201
then
198202
memory_mode="Shared_Sram"
203+
if [[ ${target} =~ "ethos-u65" ]]
204+
then
205+
memory_mode="Sram_Only"
206+
fi
199207
if [[ ${target} =~ "ethos-u85" ]]
200208
then
201209
memory_mode="Dedicated_Sram_384KB"
@@ -208,7 +216,7 @@ then
208216
fi
209217

210218
target_cpu="cortex-m85"
211-
if [[ ${target} =~ "ethos-u55" ]]
219+
if [[ ${target} =~ "ethos-u55" || ${target} =~ "ethos-u65" ]]
212220
then
213221
target_cpu="cortex-m55"
214222
fi

0 commit comments

Comments
 (0)