Skip to content

Commit ecfa4b4

Browse files
committed
Add bundled IO support to portable executor runner
Executor runner supports both models with/wo bundled io in same path and EXECUTORCH_BUILD_DEVTOOLS=ON is now required to build it. Adds tests in Arm backend for testing this/depending on this. Except for enabling bundle-io for VGF backend where applicable, some additional resnets model tests are enabled as well. Avoids narrowing conversion errors in pte_to_header script by switching char to unsigned char. GenAI used. Blackduck scan OK. Signed-off-by: Måns Nilsson <[email protected]> Change-Id: Iffdf6c253a57b01abb02758b6ba2d1e3de25e3d8
1 parent fdfeaa4 commit ecfa4b4

File tree

9 files changed

+262
-106
lines changed

9 files changed

+262
-106
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,10 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
10721072
list(APPEND _executor_runner_libs etdump flatccrt)
10731073
endif()
10741074

1075+
if(EXECUTORCH_BUILD_DEVTOOLS)
1076+
list(APPEND _executor_runner_libs bundled_program)
1077+
endif()
1078+
10751079
add_executable(executor_runner ${_executor_runner__srcs})
10761080
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
10771081
target_link_options_gc_sections(executor_runner)

backends/arm/scripts/build_executor_runner_vkml.sh

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,40 @@
66

77
set -eu
88

9-
script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
9+
script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
1010
et_root_dir=$(cd ${script_dir}/../../.. && pwd)
1111
et_root_dir=$(realpath ${et_root_dir})
1212
setup_path_script=${et_root_dir}/examples/arm/ethos-u-scratch/setup_path.sh
1313
_setup_msg="please refer to ${et_root_dir}/examples/arm/setup.sh to properly install necessary tools."
14-
source "${script_dir}/utils.sh"
15-
1614
build_type="Release"
1715
build_with_etdump=false
1816
extra_build_flags=""
1917
output_folder="cmake-out-vkml"
18+
build_with_etdump_flags="-DEXECUTORCH_ENABLE_EVENT_TRACER=OFF"
19+
20+
source "${script_dir}/utils.sh"
21+
2022

21-
build_with_etdump_flags="-DEXECUTORCH_ENABLE_EVENT_TRACER=OFF -DEXECUTORCH_BUILD_DEVTOOLS=OFF"
2223
help() {
2324
echo "Usage: $(basename $0) [options]"
2425
echo "Options:"
25-
echo " --build_type=<TYPE> Build with Release, Debug or RelWithDebInfo, default is ${build_type}"
26-
echo " --etdump Adds Devtools etdump support to track timing, etdump area will be base64 encoded in the log"
27-
echo " --extra_build_flags=<FLAGS> Extra flags to pass to cmake. Default: none "
28-
echo " --output=<FOLDER> Output folder Default: $(output_folder)"
26+
echo " --build_type=<TYPE> Build with Release, Debug or RelWithDebInfo, default is ${build_type}"
27+
echo " --etdump Adds Devtools etdump support to track timing, etdump area will be base64 encoded in the log"
28+
echo " --extra_build_flags=<FLAGS> Extra flags to pass to cmake. Default: none "
29+
echo " --output=<FOLDER> Output folder Default: $(output_folder)"
2930
exit 0
3031
}
3132

3233
for arg in "$@"; do
3334
case $arg in
34-
-h|--help) help ;;
35-
--build_type=*) build_type="${arg#*=}";;
36-
--etdump) build_with_etdump=true ;;
37-
--extra_build_flags=*) extra_build_flags="${arg#*=}";;
38-
--output=*) output_folder="${arg#*=}";;
39-
--select_ops_list=*) select_ops_list="${arg#*=}";;
40-
*)
41-
;;
35+
-h|--help) help ;;
36+
--build_type=*) build_type="${arg#*=}";;
37+
--etdump) build_with_etdump=true ;;
38+
--extra_build_flags=*) extra_build_flags="${arg#*=}";;
39+
--output=*) output_folder="${arg#*=}";;
40+
--select_ops_list=*) select_ops_list="${arg#*=}";;
41+
*)
42+
;;
4243
esac
4344
done
4445

@@ -52,23 +53,24 @@ source ${setup_path_script}
5253
mkdir -p "${output_folder}"
5354
output_folder=$(realpath "${output_folder}")
5455

55-
echo "--------------------------------------------------------------------------------"
56-
echo "Build Arm VKML executor runner: '${output_folder}' with extra build flags: ${extra_build_flags}"
57-
echo "--------------------------------------------------------------------------------"
58-
5956
cd ${et_root_dir}/examples/arm/executor_runner
6057

6158
if [ "$build_with_etdump" = true ] ; then
62-
build_with_etdump_flags="-DEXECUTORCH_ENABLE_EVENT_TRACER=ON -DEXECUTORCH_BUILD_DEVTOOLS=ON"
59+
build_with_etdump_flags="-DEXECUTORCH_ENABLE_EVENT_TRACER=ON"
6360
fi
6461

65-
echo "Building with extra flags: ${build_with_etdump_flags} ${extra_build_flags}"
62+
echo "-----------------------------------------------------------------------------------------------"
63+
echo "Build Arm VKML executor runner: '${output_folder}' with extra build flags: "
64+
echo "${build_with_etdump_flags} ${extra_build_flags}"
65+
echo "-----------------------------------------------------------------------------------------------"
66+
6667
cmake \
6768
-S "${et_root_dir}" \
6869
-B "${output_folder}" \
6970
-Wall \
7071
-Werror \
7172
-DCMAKE_BUILD_TYPE=${build_type} \
73+
-DCMAKE_CXX_FLAGS="${extra_build_flags} ${CMAKE_CXX_FLAGS:-}" \
7274
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
7375
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
7476
-DEXECUTORCH_BUILD_EXTENSION_NAMED_DATA_MAP=ON \
@@ -80,9 +82,9 @@ cmake \
8082
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
8183
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED_AOT=ON \
8284
-DEXECUTORCH_ENABLE_LOGGING=ON \
85+
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
8386
-DPYTHON_EXECUTABLE="$(which python3)" \
84-
${build_with_etdump_flags} \
85-
${extra_build_flags}
87+
${build_with_etdump_flags}
8688

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

backends/arm/scripts/run_vkml.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ hash ${converter} \
5555
|| { echo "Could not find ${converter} on PATH, ${_setup_msg}"; exit 1; }
5656

5757

58+
runner=$(find ${build_path} -name executor_runner -type f)
5859

59-
runner="${build_path}/executor_runner"
6060

6161
echo "--------------------------------------------------------------------------------"
6262
echo "Running ${model} with ${runner}"

backends/arm/test/test_arm_baremetal.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,11 @@ test_run_vkml() { # End to End model tests using run.sh
190190

191191
echo "${TEST_SUITE_NAME}: Test VKML"
192192
out_folder="arm_test/test_run"
193-
examples/arm/run.sh --et_build_root=${out_folder} --target=vgf --model_name=add --output=${out_folder}/runner
194-
examples/arm/run.sh --et_build_root=${out_folder} --target=vgf --model_name=mul --output=${out_folder}/runner
193+
examples/arm/run.sh --et_build_root=${out_folder} --target=vgf --model_name=add --output=${out_folder}/runner --bundleio
194+
examples/arm/run.sh --et_build_root=${out_folder} --target=vgf --model_name=mul --output=${out_folder}/runner --bundleio
195195

196-
examples/arm/run.sh --et_build_root=${out_folder} --target=vgf --model_name=qadd --output=${out_folder}/runner
197-
examples/arm/run.sh --et_build_root=${out_folder} --target=vgf --model_name=qops --output=${out_folder}/runner
196+
examples/arm/run.sh --et_build_root=${out_folder} --target=vgf --model_name=qadd --output=${out_folder}/runner --bundleio
197+
examples/arm/run.sh --et_build_root=${out_folder} --target=vgf --model_name=qops --output=${out_folder}/runner --bundleio
198198

199199
echo "${TEST_SUITE_NAME}: PASS"
200200
}
@@ -254,8 +254,8 @@ test_models_vkml() { # End to End model tests using model_test.py
254254

255255
# VKML
256256
echo "${TEST_SUITE_NAME}: Test target VKML"
257-
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=vgf --model=mv2
258-
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=vgf --no_quantize --model=mv2
257+
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=vgf --model=resnet18 --extra_flags="-DET_BUNDLE_IO_ATOL=0.2 -DET_BUNDLE_IO_RTOL=0.2"
258+
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=vgf --model=resnet50 --extra_flags="-DET_BUNDLE_IO_ATOL=0.2 -DET_BUNDLE_IO_RTOL=0.2"
259259

260260
echo "${TEST_SUITE_NAME}: PASS"
261261
}

backends/arm/test/test_model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,18 @@ def build_pte(
129129
no_intermediate: bool,
130130
no_quantize: bool,
131131
):
132-
pte_file_ending = "pte"
133132
command_list = [
134133
"python3",
135134
"-m",
136135
"examples.arm.aot_arm_compiler",
137136
"--delegate",
137+
"--bundleio",
138138
f"--model_name={model_name}",
139139
f"--target={target}",
140140
f"--output={build_output}",
141141
]
142142

143143
if "vgf" != target:
144-
pte_file_ending = "bpte"
145-
command_list.append("--bundleio")
146144
command_list.append(f"--system_config={system_config}")
147145
command_list.append(f"--memory_mode={memory_mode}")
148146

@@ -154,6 +152,7 @@ def build_pte(
154152

155153
run_external_cmd(command_list)
156154

155+
pte_file_ending = "bpte"
157156
pte_file = os.path.join(
158157
output, f"{model_name}_arm_delegate_{args.target}.{pte_file_ending}"
159158
)
@@ -211,6 +210,7 @@ def build_vkml_runtime(
211210
extra_flags: str,
212211
build_path: str,
213212
):
213+
# Note bundleio will be automatically detected.
214214
run_external_cmd(
215215
[
216216
"bash",

examples/arm/executor_runner/pte_to_header.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def input_file_path(path):
5959
if __name__ == "__main__":
6060
args = parser.parse_args()
6161
outfile = os.path.join(args.outdir, args.outfile)
62-
attr = f'__attribute__((section("{args.section}"), aligned(16))) char '
62+
attr = f'__attribute__((section("{args.section}"), aligned(16))) unsigned char '
6363

6464
with open(args.pte, "rb") as fr, open(outfile, "w") as fw:
6565
data = fr.read()

examples/arm/run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ for i in "${!test_model[@]}"; do
306306
echo "Build and run for VKML, (target: ${target})"
307307
set -x
308308
backends/arm/scripts/build_executor_runner_vkml.sh --build_type=${build_type} \
309+
--pte="${pte_file}" \
309310
--extra_build_flags="${extra_build_flags}" \
310311
--output="${output_folder}"
311312
if [ "$build_only" = false ] ; then

0 commit comments

Comments
 (0)