Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backends/arm/scripts/build_executor_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ help() {
echo " --memory_mode=<CONFIG> Vela memory mode, used for setting the Timing Adapter parameters of the Corstone platforms."
echo " Valid values are Shared_Sram(for Ethos-U55, Ethos-U65, Ethos-85), Sram_Only(for Ethos-U55, Ethos-U65, Ethos-U85) or Dedicated_Sram(for Ethos-U65, Ethos-U85)."
echo " Default: Shared_Sram for the Ethos-U55 and Sram_Only for the Ethos-U85"
echo " --etdump Adds Devtools etdump support to track timing, etdump area will be base64 encoded in the log"
echo " --etdump Adds Devtools etdump support to track timing and output, etdump area will be base64 encoded in the log"
echo " --extra_build_flags=<FLAGS> Extra flags to pass to cmake like -DET_ARM_BAREMETAL_METHOD_ALLOCATOR_POOL_SIZE=60000 Default: none "
echo " --output=<FOLDER> Output folder Default: <MODEL>/<MODEL>_<TARGET INFO>.pte"
echo " --et_build_root=<FOLDER> Build output root folder to use, defaults to ${et_build_root}"
Expand Down Expand Up @@ -161,7 +161,7 @@ if [ "$bundleio" = true ] ; then
fi

if [ "$build_with_etdump" = true ] ; then
build_with_etdump_flags=" -DEXECUTORCH_ENABLE_EVENT_TRACER=ON "
build_with_etdump_flags=" -DEXECUTORCH_ENABLE_EVENT_TRACER=ON -DET_DUMP_INTERMEDIATE_OUTPUTS=ON "
fi

echo "Building with BundleIO/etdump/extra flags: ${build_bundleio_flags} ${build_with_etdump_flags} ${extra_build_flags}"
Expand Down
17 changes: 14 additions & 3 deletions backends/arm/scripts/run_fvp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ elf_file=""
data_file=""
target="ethos-u55-128"
timeout="600"
etrecord_file=""

help() {
echo "Usage: $(basename $0) [options]"
Expand All @@ -29,6 +30,7 @@ help() {
echo " --data=<FILE>@<ADDRESS> Place a file in memory at this address, useful to emulate a PTE flashed into memory instead as part of the code."
echo " --target=<TARGET> Target to build and run for Default: ${target}"
echo " --timeout=<TIME_IN_SEC> Maximum target runtime, used to detect hanging, might need to be higer on large models Default: ${timeout}"
echo " --etrecord=<FILE> If ETDump is used you can supply a ETRecord file matching the PTE"
exit 0
}

Expand All @@ -39,6 +41,7 @@ for arg in "$@"; do
--data=*) data_file="--data ${arg#*=}";;
--target=*) target="${arg#*=}";;
--timeout=*) timeout="${arg#*=}";;
--etrecord=*) etrecord_file="${arg#*=}";;
*)
;;
esac
Expand Down Expand Up @@ -115,15 +118,23 @@ echo "Checking for a etdump in log"
! grep "#\[RUN THIS\]" ${log_file} >/dev/null
if [ $? != 0 ]; then
echo "Found ETDump in log!"
devtools_extra_args=""
echo "#!/bin/sh" > etdump_script.sh
sed -n '/^#\[RUN THIS\]$/,/^#\[END\]$/p' ${log_file} >> etdump_script.sh
# You can run etdump_script.sh if you do
# $ chmod a+x etdump_script.sh
# $ ./etdump_script.sh
# But lets not trust the script as a bad patch would run bad code on your machine
grep ">etdump.bin" etdump_script.sh | cut -d\" -f2- | cut -d\" -f1 >etdump.base64
base64 -d etdump.base64 >etdump.bin
python3 -m devtools.inspector.inspector_cli --etdump_path etdump.bin --source_time_scale cycles --target_time_scale cycles
grep ">etdump.bin" etdump_script.sh | cut -d\" -f2- | cut -d\" -f1 | base64 -d >etdump.bin
! grep ">debug_buffer.bin" etdump_script.sh >/dev/null
if [ $? != 0 ]; then
grep ">debug_buffer.bin" etdump_script.sh | cut -d\" -f2- | cut -d\" -f1 | base64 -d >debug_buffer.bin
devtools_extra_args="${devtools_extra_args} --debug_buffer_path debug_buffer.bin"
fi
if [[ ${etrecord_file} != "" ]]; then
devtools_extra_args="${devtools_extra_args} --etrecord_path ${etrecord_file}"
fi
python3 -m devtools.inspector.inspector_cli --etdump_path etdump.bin ${devtools_extra_args} --source_time_scale cycles --target_time_scale cycles
fi

echo "Checking for problems in log:"
Expand Down
2 changes: 1 addition & 1 deletion backends/arm/test/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def build_ethosu_runtime(
"--build_type=Release",
f"--system_config={system_config}",
f"--memory_mode={memory_mode}",
f"--extra_build_flags=-DET_DUMP_OUTPUT=OFF {extra_flags}",
f"--extra_build_flags=-DET_LOG_DUMP_OUTPUT=OFF {extra_flags}",
f"--output={elf_build_path}",
]
)
Expand Down
136 changes: 95 additions & 41 deletions examples/arm/executor_runner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,59 @@
cmake_minimum_required(VERSION 3.20)
project(arm_executor_runner)

option(SEMIHOSTING "Enable semihosting" OFF)
option(
ET_ARM_BAREMETAL_METHOD_ALLOCATOR_POOL_SIZE
"Set ET_ARM_BAREMETAL_METHOD_ALLOCATOR_POOL_SIZE to specify memory alloction pool size"
OFF
)
option(
ET_MODEL_PTE_ADDR
"Place in memory that the PTE file is located/flashed, if set to OFF the PTE is built into the code as a big data area."
OFF
)
option(ET_BUNDLE_IO "Set to compile in BundleIO support" OFF)
option(ET_ATOL "Set atol to use for BundleIO testing" OFF)
option(ET_RTOL "Set rtol to use for BundleIO testing" OFF)
option(ET_DUMP_INPUT "Dump input in log" OFF)
option(ET_DUMP_OUTPUT "Dump output in log" ON)
option(FETCH_ETHOS_U_CONTENT
"Fetch ethos_u dependencies instead of relying on pre-downloads" ON
)

set(ET_NUM_INFERENCES
"1"
CACHE STRING "Number of inferences to run"
)

option(ET_LOG_DUMP_INPUT "Dump input in log" OFF)
option(ET_LOG_DUMP_OUTPUT "Dump output in log" ON)

option(ET_BUNDLE_IO "Set to compile in BundleIO support" OFF)
set(ET_ATOL
"0.01"
CACHE STRING "Set atol to use for BundleIO testing (Requires ET_BUNDLE_IO)"
)
set(ET_RTOL
"0.01"
CACHE STRING "Set atol to use for BundleIO testing (Requires ET_BUNDLE_IO)"
)

option(
ET_DUMP_OUTPUTS
"Collect and print outputs as a base64 buffer in the log (Requires EXECUTORCH_ENABLE_EVENT_TRACER)"
OFF
)
option(
ET_DUMP_INTERMEDIATE_OUTPUTS
"Collect and print intermediate outputs as a base64 buffer in the log (Requires EXECUTORCH_ENABLE_EVENT_TRACER)"
OFF
)
set(ET_DEBUG_BUFFER_SIZE
"2097152"
CACHE
STRING
"Size of buffer to collect intermediate outputs/outputs buffers (Requires EXECUTORCH_ENABLE_EVENT_TRACER and ET_DUMP_OUTPUTS or ET_DUMP_INTERMEDIATE_OUTPUTS)"
)

option(SEMIHOSTING "Enable semihosting" OFF)

option(
ET_ARM_BAREMETAL_METHOD_ALLOCATOR_POOL_SIZE
"Set ET_ARM_BAREMETAL_METHOD_ALLOCATOR_POOL_SIZE to specify memory alloction pool size"
OFF
)

option(FETCH_ETHOS_U_CONTENT
"Fetch ethos_u dependencies instead of relying on pre-downloads" ON
)

if(NOT DEFINED ET_MODEL_PTE_ADDR
AND NOT DEFINED ET_PTE_FILE_PATH
AND NOT DEFINED SEMIHOSTING
Expand Down Expand Up @@ -322,37 +351,29 @@ if(NOT ${ET_MODEL_PTE_ADDR} AND NOT SEMIHOSTING)
add_dependencies(arm_executor_runner gen_model_header)
endif()

if(SEMIHOSTING)
target_compile_definitions(arm_executor_runner PUBLIC SEMIHOSTING)
endif()

if(ET_ARM_BAREMETAL_METHOD_ALLOCATOR_POOL_SIZE)
if(ET_MODEL_PTE_ADDR)
target_compile_definitions(
arm_executor_runner
PUBLIC
ET_ARM_BAREMETAL_METHOD_ALLOCATOR_POOL_SIZE=${ET_ARM_BAREMETAL_METHOD_ALLOCATOR_POOL_SIZE}
arm_executor_runner PUBLIC -DET_MODEL_PTE_ADDR=${ET_MODEL_PTE_ADDR}
)
endif()

target_compile_definitions(
arm_executor_runner
PUBLIC
ET_ARM_BAREMETAL_SCRATCH_TEMP_ALLOCATOR_POOL_SIZE=${ET_ARM_BAREMETAL_SCRATCH_TEMP_ALLOCATOR_POOL_SIZE}
)
if(DEFINED ET_ARM_BAREMETAL_FAST_SCRATCH_TEMP_ALLOCATOR_POOL_SIZE)
if(ET_NUM_INFERENCES)
target_compile_definitions(
arm_executor_runner
PUBLIC
ET_ARM_BAREMETAL_FAST_SCRATCH_TEMP_ALLOCATOR_POOL_SIZE=${ET_ARM_BAREMETAL_FAST_SCRATCH_TEMP_ALLOCATOR_POOL_SIZE}
arm_executor_runner PUBLIC ET_NUM_INFERENCES=${ET_NUM_INFERENCES}
)
endif()

if(ET_MODEL_PTE_ADDR)
target_compile_definitions(
arm_executor_runner PUBLIC -DET_MODEL_PTE_ADDR=${ET_MODEL_PTE_ADDR}
)
if(ET_LOG_DUMP_INPUT)
target_compile_definitions(arm_executor_runner PUBLIC -DET_LOG_DUMP_INPUT)
endif()

if(ET_LOG_DUMP_OUTPUT)
target_compile_definitions(arm_executor_runner PUBLIC -DET_LOG_DUMP_OUTPUT)
endif()

# Devtool BundleIO: Use Bundle PTE with input and reference output included to
# check if it matches.

if(ET_BUNDLE_IO)
target_compile_definitions(arm_executor_runner PUBLIC -DET_BUNDLE_IO)
endif()
Expand All @@ -365,17 +386,50 @@ if(ET_RTOL)
target_compile_definitions(arm_executor_runner PUBLIC ET_RTOL=${ET_RTOL})
endif()

if(ET_DUMP_INPUT)
target_compile_definitions(arm_executor_runner PUBLIC -DET_DUMP_INPUT)
# Devtools ETDump: Speed and dumping output

if(ET_DUMP_OUTPUTS)
target_compile_definitions(arm_executor_runner PUBLIC -DET_DUMP_OUTPUTS)
endif()

if(ET_DUMP_OUTPUT)
target_compile_definitions(arm_executor_runner PUBLIC -DET_DUMP_OUTPUT)
if(ET_DUMP_INTERMEDIATE_OUTPUTS)
target_compile_definitions(
arm_executor_runner PUBLIC -DET_DUMP_INTERMEDIATE_OUTPUTS
)
endif()

if(ET_NUM_INFERENCES)
if(ET_DEBUG_BUFFER_SIZE)
target_compile_definitions(
arm_executor_runner PUBLIC ET_NUM_INFERENCES=${ET_NUM_INFERENCES}
arm_executor_runner PUBLIC ET_DEBUG_BUFFER_SIZE=${ET_DEBUG_BUFFER_SIZE}
)
endif()

# Semihosting FVP (FVP Simulator can access host filesystem)

if(SEMIHOSTING)
target_compile_definitions(arm_executor_runner PUBLIC SEMIHOSTING)
endif()

# Memory buffer sizes for Executorch flow

if(ET_ARM_BAREMETAL_METHOD_ALLOCATOR_POOL_SIZE)
target_compile_definitions(
arm_executor_runner
PUBLIC
ET_ARM_BAREMETAL_METHOD_ALLOCATOR_POOL_SIZE=${ET_ARM_BAREMETAL_METHOD_ALLOCATOR_POOL_SIZE}
)
endif()

target_compile_definitions(
arm_executor_runner
PUBLIC
ET_ARM_BAREMETAL_SCRATCH_TEMP_ALLOCATOR_POOL_SIZE=${ET_ARM_BAREMETAL_SCRATCH_TEMP_ALLOCATOR_POOL_SIZE}
)
if(DEFINED ET_ARM_BAREMETAL_FAST_SCRATCH_TEMP_ALLOCATOR_POOL_SIZE)
target_compile_definitions(
arm_executor_runner
PUBLIC
ET_ARM_BAREMETAL_FAST_SCRATCH_TEMP_ALLOCATOR_POOL_SIZE=${ET_ARM_BAREMETAL_FAST_SCRATCH_TEMP_ALLOCATOR_POOL_SIZE}
)
endif()

Expand Down
Loading
Loading