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
27 changes: 16 additions & 11 deletions backends/arm/scripts/build_executor_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ build_with_etdump_flags=" -DEXECUTORCH_ENABLE_EVENT_TRACER=OFF "
help() {
echo "Usage: $(basename $0) [options]"
echo "Options:"
echo " --pte=<PTE_FILE> pte file (genrated by the aot_arm_compier from the model to include in the elf"
echo " --pte=<PTE_FILE>|semihosting pte file (generated by the aot_arm_compier from the model to include in the elf), or semihosting to supply pte at runtime."
echo " --target=<TARGET> Target to build and run for Default: ${target}"
echo " --build_type=<TYPE> Build with Release, Debug or RelWithDebInfo, default is ${build_type}"
echo " --bundleio Support both pte and Bundle IO bpte using Devtools BundelIO with Input/RefOutput included"
Expand Down Expand Up @@ -93,18 +93,24 @@ toolchain_cmake=$(realpath ${toolchain_cmake})

source ${setup_path_script}

pte_file=$(realpath ${pte_file})
if [[ ${pte_file} == "semihosting" ]]; then
extra_build_flags="${extra_build_flags} -DSEMIHOSTING=ON"
else
pte_file=$(realpath ${pte_file})
extra_build_flags="${extra_build_flags} -DET_PTE_FILE_PATH:PATH='${pte_file}'"
fi
ethosu_tools_dir=$(realpath ${ethosu_tools_dir})
ethos_u_root_dir="$ethosu_tools_dir/ethos-u"
mkdir -p "${ethos_u_root_dir}"
ethosu_tools_dir=$(realpath ${ethos_u_root_dir})

et_build_dir=${et_build_root}/cmake-out
mkdir -p ${et_build_dir}
et_build_dir=$(realpath ${et_build_dir})

if [ "$output_folder_set" = false ] ; then
# remove file ending
output_folder=${pte_file%.*}
output_folder=${pte_file%.*}/cmake-out
fi

if [[ ${system_config} == "" ]]
Expand Down Expand Up @@ -134,7 +140,7 @@ else
target_cpu=cortex-m85
fi
echo "--------------------------------------------------------------------------------"
echo "Build Arm ${toolchain/-gcc/} executor_runner for ${target} with ${pte_file} using ${system_config} ${memory_mode} ${extra_build_flags} to '${output_folder}/cmake-out'"
echo "Build Arm ${toolchain/-gcc/} executor_runner for ${target} with ${pte_file} using ${system_config} ${memory_mode} ${extra_build_flags} to '${output_folder}'"
echo "--------------------------------------------------------------------------------"

cd ${et_root_dir}/examples/arm/executor_runner
Expand All @@ -154,7 +160,6 @@ cmake \
-DTARGET_CPU=${target_cpu} \
-DET_DIR_PATH:PATH=${et_root_dir} \
-DET_BUILD_DIR_PATH:PATH=${et_build_dir} \
-DET_PTE_FILE_PATH:PATH="${pte_file}" \
-DETHOS_SDK_PATH:PATH=${ethos_u_root_dir} \
-DETHOSU_TARGET_NPU_CONFIG=${target} \
${build_bundleio_flags} \
Expand All @@ -164,14 +169,14 @@ cmake \
-DMEMORY_MODE=${memory_mode} \
-DEXECUTORCH_SELECT_OPS_LIST="${select_ops_list}" \
${extra_build_flags} \
-B ${output_folder}/cmake-out
-B ${output_folder}

echo "[${BASH_SOURCE[0]}] Configured CMAKE"

cmake --build ${output_folder}/cmake-out -j$(nproc) -- arm_executor_runner
cmake --build ${output_folder} -j$(nproc) -- arm_executor_runner

echo "[${BASH_SOURCE[0]}] Generated ${toolchain} elf file:"
find ${output_folder}/cmake-out -name "arm_executor_runner"
echo "executable_text: $(find ${output_folder}/cmake-out -name arm_executor_runner -exec ${toolchain/-gcc/-size} {} \; | grep -v filename | awk '{print $1}') bytes"
echo "executable_data: $(find ${output_folder}/cmake-out -name arm_executor_runner -exec ${toolchain/-gcc/-size} {} \; | grep -v filename | awk '{print $2}') bytes"
echo "executable_bss: $(find ${output_folder}/cmake-out -name arm_executor_runner -exec ${toolchain/-gcc/-size} {} \; | grep -v filename | awk '{print $3}') bytes"
find ${output_folder} -name "arm_executor_runner"
echo "executable_text: $(find ${output_folder} -name arm_executor_runner -exec ${toolchain/-gcc/-size} {} \; | grep -v filename | awk '{print $1}') bytes"
echo "executable_data: $(find ${output_folder} -name arm_executor_runner -exec ${toolchain/-gcc/-size} {} \; | grep -v filename | awk '{print $2}') bytes"
echo "executable_bss: $(find ${output_folder} -name arm_executor_runner -exec ${toolchain/-gcc/-size} {} \; | grep -v filename | awk '{print $3}') bytes"
52 changes: 5 additions & 47 deletions backends/arm/test/setup_testing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,10 @@

set -eu

script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
et_root_dir=$(cd ${script_dir}/../../.. && pwd)
ethos_u_root_dir=${et_root_dir}/examples/arm/ethos-u-scratch/ethos-u

toolchain_cmake=${et_root_dir}/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
et_build_dir=${et_root_dir}/arm_test/cmake-out
script_dir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
et_root_dir=$(realpath "${script_dir}/../../..")
build_executor_runner=${et_root_dir}/backends/arm/scripts/build_executor_runner.sh
build_root_test_dir=${et_root_dir}/arm_test/arm_semihosting_executor_runner

# Build Arm Baremetal executor_runner in semihosting mode.
# Put in backends/arm/test/res to be used by unit tests.
function build_semihosting_executorch_runner() {
target_board=$1
system_config=$2
build_test_dir=${build_root_test_dir}_${target_board}
echo "[${FUNCNAME[0]}] Configuring ${target_board} with system config ${system_config}"
if [[ ${target_board} == "corstone-300" ]]; then
local target_cpu=cortex-m55
elif [[ ${target_board} == "corstone-320" ]]; then
local target_cpu=cortex-m85
else
echo "[${FUNCNAME[0]}] ERROR: Invalid target_board specified!"
exit 1
fi
cd ${et_root_dir}/examples/arm/executor_runner
pwd
mkdir -p ${build_test_dir}
cmake -DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DTARGET_CPU=${target_cpu} \
-DSEMIHOSTING=ON \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${build_test_dir} \
-DETHOS_SDK_PATH:PATH=${ethos_u_root_dir} \
-DET_DIR_PATH:PATH=${et_root_dir} \
-DET_BUILD_DIR_PATH:PATH=${et_build_dir} \
-DPYTHON_EXECUTABLE=$(which python3) \
-DSYSTEM_CONFIG=${system_config} \
-B ${build_test_dir}
echo "[${FUNCNAME[0]}] Configured CMAKE"

n=$(nproc)
cmake --build ${build_test_dir} -j"$((n - 5))" -- arm_executor_runner
echo "[${FUNCNAME[0]}] Generated baremetal elf file: with semihosting enabled"
find ${build_test_dir} -name "arm_executor_runner"
}

# Use most optimal system_configs for testing
build_semihosting_executorch_runner corstone-300 Ethos_U55_High_End_Embedded

build_semihosting_executorch_runner corstone-320 Ethos_U85_SYS_DRAM_Mid
${build_executor_runner} --pte=semihosting --target=ethos-u55-128 --output="${build_root_test_dir}_corstone-300"
${build_executor_runner} --pte=semihosting --target=ethos-u85-128 --output="${build_root_test_dir}_corstone-320"
3 changes: 2 additions & 1 deletion backends/arm/test/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def build_ethosu_runtime(
extra_flags: str,
elf_build_path: str,
):
elf_build_path = os.path.join(elf_build_path, "cmake-out")
run_external_cmd(
[
"bash",
Expand All @@ -174,7 +175,7 @@ def build_ethosu_runtime(
]
)

elf_file = os.path.join(elf_build_path, "cmake-out", "arm_executor_runner")
elf_file = os.path.join(elf_build_path, "arm_executor_runner")
return elf_file


Expand Down
Loading