Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion backends/arm/scripts/run_vkml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ 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}"
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_flags="-DET_BUNDLE_IO_ATOL=0.2 -DET_BUNDLE_IO_RTOL=0.2"
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"

echo "${TEST_SUITE_NAME}: PASS"
}
Expand Down
6 changes: 3 additions & 3 deletions backends/arm/test/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,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 @@ -154,6 +152,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 @@ -217,6 +216,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 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 @@ -307,7 +307,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