Skip to content
Open
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
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ if(EXECUTORCH_ENABLE_EVENT_TRACER)
add_definitions(-DET_EVENT_TRACER_ENABLED)
endif()

if(EXECUTORCH_ENABLE_BUNDLE_IO)
add_definitions(-DET_BUNDLE_IO_ENABLED)
endif()

# -ffunction-sections -fdata-sections: breaks function and data into sections so
# they can be properly gc'd. -s: strip symbol.
if(WIN32)
Expand Down Expand Up @@ -1072,6 +1076,10 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
list(APPEND _executor_runner_libs etdump flatccrt)
endif()

if(EXECUTORCH_ENABLE_BUNDLE_IO)
list(APPEND _executor_runner_libs bundled_program)
endif()

add_executable(executor_runner ${_executor_runner__srcs})
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
target_link_options_gc_sections(executor_runner)
Expand Down
54 changes: 30 additions & 24 deletions backends/arm/scripts/build_executor_runner_vkml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,43 @@

set -eu

script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
et_root_dir=$(cd ${script_dir}/../../.. && pwd)
et_root_dir=$(realpath ${et_root_dir})
setup_path_script=${et_root_dir}/examples/arm/ethos-u-scratch/setup_path.sh
_setup_msg="please refer to ${et_root_dir}/examples/arm/setup.sh to properly install necessary tools."
source "${script_dir}/utils.sh"

build_type="Release"
build_with_etdump=false
extra_build_flags=""
output_folder="cmake-out-vkml"
build_with_etdump_flags="-DEXECUTORCH_ENABLE_EVENT_TRACER=OFF"
build_with_bundleio_flags="-DEXECUTORCH_ENABLE_BUNDLE_IO=OFF"

source "${script_dir}/utils.sh"


build_with_etdump_flags="-DEXECUTORCH_ENABLE_EVENT_TRACER=OFF -DEXECUTORCH_BUILD_DEVTOOLS=OFF"
help() {
echo "Usage: $(basename $0) [options]"
echo "Options:"
echo " --build_type=<TYPE> Build with Release, Debug or RelWithDebInfo, default is ${build_type}"
echo " --etdump Adds Devtools etdump support to track timing, etdump area will be base64 encoded in the log"
echo " --extra_build_flags=<FLAGS> Extra flags to pass to cmake. Default: none "
echo " --output=<FOLDER> Output folder Default: $(output_folder)"
echo " --build_type=<TYPE> Build with Release, Debug or RelWithDebInfo, default is ${build_type}"
echo " --etdump Adds Devtools etdump support to track timing, etdump area will be base64 encoded in the log"
echo " --extra_build_flags=<FLAGS> Extra flags to pass to cmake. Default: none "
echo " --output=<FOLDER> Output folder Default: $(output_folder)"
echo " --bundleio Support BundleIO using Devtools with Input/RefOutput included"
exit 0
}

for arg in "$@"; do
case $arg in
-h|--help) help ;;
--build_type=*) build_type="${arg#*=}";;
--etdump) build_with_etdump=true ;;
--extra_build_flags=*) extra_build_flags="${arg#*=}";;
--output=*) output_folder="${arg#*=}";;
--select_ops_list=*) select_ops_list="${arg#*=}";;
*)
;;
-h|--help) help ;;
--build_type=*) build_type="${arg#*=}";;
--etdump) build_with_etdump=true ;;
--extra_build_flags=*) extra_build_flags="${arg#*=}";;
--output=*) output_folder="${arg#*=}";;
--select_ops_list=*) select_ops_list="${arg#*=}";;
--bundleio) build_with_bundleio_flags="-DEXECUTORCH_ENABLE_BUNDLE_IO=ON" ;;
*)
;;
esac
done

Expand All @@ -52,23 +56,24 @@ source ${setup_path_script}
mkdir -p "${output_folder}"
output_folder=$(realpath "${output_folder}")

echo "--------------------------------------------------------------------------------"
echo "Build Arm VKML executor runner: '${output_folder}' with extra build flags: ${extra_build_flags}"
echo "--------------------------------------------------------------------------------"

cd ${et_root_dir}/examples/arm/executor_runner

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

echo "Building with extra flags: ${build_with_etdump_flags} ${extra_build_flags}"
echo "-----------------------------------------------------------------------------------------------"
echo "Build Arm VKML executor runner: '${output_folder}' with extra build flags: "
echo "${build_with_etdump_flags} ${build_with_bundleio_flags} ${extra_build_flags}"
echo "-----------------------------------------------------------------------------------------------"

cmake \
-S "${et_root_dir}" \
-B "${output_folder}" \
-Wall \
-Werror \
-DCMAKE_BUILD_TYPE=${build_type} \
-DCMAKE_CXX_FLAGS="${extra_build_flags} ${CMAKE_CXX_FLAGS:-}" \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
-DEXECUTORCH_BUILD_EXTENSION_NAMED_DATA_MAP=ON \
Expand All @@ -80,9 +85,10 @@ cmake \
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED_AOT=ON \
-DEXECUTORCH_ENABLE_LOGGING=ON \
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
-DPYTHON_EXECUTABLE="$(which python3)" \
${build_with_etdump_flags} \
${extra_build_flags}
${build_with_etdump_flags} \
${build_with_bundleio_flags}

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

Expand Down
8 changes: 5 additions & 3 deletions backends/arm/scripts/run_vkml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ _setup_msg="please refer to ${et_root_dir}/examples/arm/setup.sh to properly ins


model=""
opt_flags=""
build_path="cmake-out-vkml"
converter="model-converter"

Expand All @@ -33,6 +34,7 @@ help() {
for arg in "$@"; do
case $arg in
-h|--help) help ;;
--optional_flags=*) opt_flags="${arg#*=}";;
--model=*) model="${arg#*=}";;
--build_path=*) build_path="${arg#*=}";;
*)
Expand All @@ -55,11 +57,11 @@ hash ${converter} \
|| { echo "Could not find ${converter} on PATH, ${_setup_msg}"; exit 1; }


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

runner="${build_path}/executor_runner"

echo "--------------------------------------------------------------------------------"
echo "Running ${model} with ${runner}"
echo "Running ${model} with ${runner} ${opt_flags}"
echo "WARNING: The VK_ML layer driver will not provide accurate performance information"
echo "--------------------------------------------------------------------------------"

Expand All @@ -75,7 +77,7 @@ fi
log_file=$(mktemp)


${nobuf} ${runner} -model_path ${model} | tee ${log_file}
${nobuf} ${runner} -model_path ${model} ${opt_flags} | tee ${log_file}
echo "[${BASH_SOURCE[0]}] execution complete, $?"

# Most of these can happen for bare metal or linx executor_runner runs.
Expand Down
12 changes: 6 additions & 6 deletions backends/arm/test/test_arm_baremetal.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ test_run_vkml() { # End to End model tests using run.sh

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

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

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

# VKML
echo "${TEST_SUITE_NAME}: Test target VKML"
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=vgf --model=mv2
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=vgf --no_quantize --model=mv2
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=vgf --model=resnet18 --extra_runtime_flags="--bundleio_atol=0.2 --bundleio_rtol=0.2"
python3 backends/arm/test/test_model.py --test_output=arm_test/test_model --target=vgf --model=resnet50 --extra_runtime_flags="--bundleio_atol=0.2 --bundleio_rtol=0.2"

echo "${TEST_SUITE_NAME}: PASS"
}
Expand Down
19 changes: 13 additions & 6 deletions backends/arm/test/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,15 @@ def get_args():
parser.add_argument(
"--extra_flags",
required=False,
default=None,
default="",
help="Extra cmake flags to pass the when building the executor_runner",
)
parser.add_argument(
"--extra_runtime_flags",
required=False,
default="",
help="Extra runtime flags to pass the final runner/executable",
)
parser.add_argument(
"--timeout",
required=False,
Expand Down Expand Up @@ -130,20 +136,18 @@ def build_pte(
no_intermediate: bool,
no_quantize: bool,
):
pte_file_ending = "pte"
command_list = [
"python3",
"-m",
"examples.arm.aot_arm_compiler",
"--delegate",
"--bundleio",
f"--model_name={model_name}",
f"--target={target}",
f"--output={build_output}",
]

if "vgf" != target:
pte_file_ending = "bpte"
command_list.append("--bundleio")
command_list.append(f"--system_config={system_config}")
command_list.append(f"--memory_mode={memory_mode}")

Expand All @@ -155,6 +159,7 @@ def build_pte(

run_external_cmd(command_list)

pte_file_ending = "bpte"
pte_file = os.path.join(
output, f"{model_name}_arm_delegate_{args.target}.{pte_file_ending}"
)
Expand Down Expand Up @@ -218,6 +223,7 @@ def build_vkml_runtime(
os.path.join(script_path, "build_executor_runner_vkml.sh"),
f"--et_build_root={et_build_root}",
"--etdump",
"--bundleio",
"--build_type=Release",
f"--extra_build_flags=-DET_DUMP_OUTPUT=OFF {extra_flags}",
f"--output={build_path}",
Expand All @@ -228,13 +234,14 @@ def build_vkml_runtime(
return runner


def run_vkml(script_path: str, pte_file: str, runner_build_path: str):
def run_vkml(script_path: str, pte_file: str, runner_build_path: str, extra_flags: str):
run_external_cmd(
[
"bash",
os.path.join(script_path, "run_vkml.sh"),
f"--model={pte_file}",
f"--build_path={runner_build_path}",
f"--optional_flags={extra_flags}",
]
)

Expand Down Expand Up @@ -297,7 +304,7 @@ def run_vkml(script_path: str, pte_file: str, runner_build_path: str):
)

start_time = time.perf_counter()
run_vkml(script_path, pte_file, build_path)
run_vkml(script_path, pte_file, build_path, args.extra_runtime_flags)
end_time = time.perf_counter()
print(
f"[Test model: {end_time - start_time:.2f} s] Tested VKML runner: {vkml_runner}"
Expand Down
2 changes: 1 addition & 1 deletion examples/arm/executor_runner/pte_to_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def input_file_path(path):
if __name__ == "__main__":
args = parser.parse_args()
outfile = os.path.join(args.outdir, args.outfile)
attr = f'__attribute__((section("{args.section}"), aligned(16))) char '
attr = f'__attribute__((section("{args.section}"), aligned(16))) unsigned char '

with open(args.pte, "rb") as fr, open(outfile, "w") as fw:
data = fr.read()
Expand Down
3 changes: 2 additions & 1 deletion examples/arm/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ for i in "${!test_model[@]}"; do
set -x
backends/arm/scripts/build_executor_runner_vkml.sh --build_type=${build_type} \
--extra_build_flags="${extra_build_flags}" \
--output="${output_folder}"
--output="${output_folder}" \
${bundleio_flag}
if [ "$build_only" = false ] ; then
backends/arm/scripts/run_vkml.sh --model=${pte_file} --build_path=${output_folder}
fi
Expand Down
5 changes: 4 additions & 1 deletion examples/devtools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# Copyright 2025 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -47,7 +48,9 @@ find_package(
)

add_executable(example_runner example_runner/example_runner.cpp)
target_compile_options(executorch INTERFACE -DET_EVENT_TRACER_ENABLED)
target_compile_options(
executorch INTERFACE -DET_EVENT_TRACER_ENABLED -DET_BUNDLE_IO_ENABLED
)

target_include_directories(
etdump INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../../devtools/include
Expand Down
Loading
Loading