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
2 changes: 1 addition & 1 deletion .github/workflows/trunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ jobs:
sudo sysctl fs.inotify.max_user_watches=1048576 # 1024 * 1024

# Test ethos-u delegate examples with run.sh
backends/arm/test/test_arm_baremetal.sh test_run_ethosu_fvp
backends/arm/test/test_arm_baremetal.sh test_full_ethosu_fvp


test-arm-reference-delegation:
Expand Down
4 changes: 2 additions & 2 deletions backends/arm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ To run the unit test suite with Corstone3x0 FVP simulator support use
backends/arm/test/test_arm_baremetal.sh test_pytest_ethosu_fvp
```

You can test to run some models with the run.sh flow
You can test to run some models with the full fvp test flow

```
backends/arm/test/test_arm_baremetal.sh test_run_ethosu_fvp
backends/arm/test/test_arm_baremetal.sh test_full_ethosu_fvp
```

## Unit tests
Expand Down
123 changes: 123 additions & 0 deletions backends/arm/scripts/build_executorch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/env bash
# 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.

# Optional parameter:
# --build_type= "Release" | "Debug" | "RelWithDebInfo"
# --etdump build with devtools-etdump support

set -eu

script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
et_root_dir=$(cd ${script_dir}/../../.. && pwd)
et_root_dir=$(realpath ${et_root_dir})
toolchain_cmake=${script_dir}/../../../examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
toolchain_cmake=$(realpath ${toolchain_cmake})



et_build_root="${et_root_dir}/arm_test"
build_type="Release"
build_with_etdump=false


help() {
echo "Usage: $(basename $0) [options]"
echo "Options:"
echo " --et_build_root=<FOLDER> Build output root folder to use, defaults to ${et_build_root}"
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"
exit 0
}

for arg in "$@"; do
case $arg in
-h|--help) help ;;
--et_build_root=*) et_build_root="${arg#*=}";;
--build_type=*) build_type="${arg#*=}";;
--etdump) build_with_etdump=true ;;
*)
;;
esac
done

et_build_dir="${et_build_root}/cmake-out"
et_build_host_dir=${et_build_root}/cmake-out-host-tools

set -x
cd "${et_root_dir}"

build_with_etdump_flags=""
if [ "$build_with_etdump" = true ] ; then
( set +x ;
echo "--------------------------------------------------------------------------------" ;
echo "Build ExecuTorch Libraries host flatcc bin ${build_type} into ${et_build_host_dir} - ${et_build_host_dir}/bin/flatcc" ;
echo "--------------------------------------------------------------------------------" )


# Build host flatcc bin
# This is a way to work around that the flatcc executable get build for target (e.g. Arm) later
# and get replaced. flatcc is a tool used on the host for etdump and BundleIO handling.
# The way to solve this is to generate it once for the host, then copy it to ${et_build_host_dir}/bin
# and later point that out with -DFLATCC_EXECUTABLE=${et_build_host_dir}/bin/flatcc later.
mkdir -p ${et_build_host_dir}
cmake \
-DCMAKE_INSTALL_PREFIX=${et_build_host_dir} \
-DCMAKE_BUILD_TYPE=${build_type} \
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
-DEXECUTORCH_ENABLE_LOGGING=ON \
-DEXECUTORCH_BUILD_ARM_BAREMETAL=ON \
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
-DEXECUTORCH_SEPARATE_FLATCC_HOST_PROJECT=ON \
-DFLATCC_ALLOW_WERROR=OFF \
-DFLATC_EXECUTABLE="$(which flatc)" \
-B"${et_build_host_dir}" \
"${et_root_dir}"

# Copy host flatcc excutable to it's saved when we build for target (Arm) later
mkdir -p ${et_build_host_dir}/bin
cp third-party/flatcc/bin/flatcc ${et_build_host_dir}/bin

# Add DevTools flags use in the Target build below
build_with_etdump_flags="-DEXECUTORCH_BUILD_DEVTOOLS=ON \
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
-DEXECUTORCH_SEPARATE_FLATCC_HOST_PROJECT=OFF \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=OFF \
-DFLATCC_ALLOW_WERROR=OFF \
-DFLATCC_EXECUTABLE=${et_build_host_dir}/bin/flatcc "
echo "build_with_etdump_flags=$build_with_etdump_flags"
fi

( set +x ;
echo "--------------------------------------------------------------------------------" ;
echo "Build ExecuTorch target libs ${build_type} into '${et_build_dir}'" ;
echo "--------------------------------------------------------------------------------" )

# Build
cmake \
-DCMAKE_INSTALL_PREFIX=${et_build_dir} \
-DCMAKE_BUILD_TYPE=${build_type} \
-DCMAKE_TOOLCHAIN_FILE="${toolchain_cmake}" \
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
-DEXECUTORCH_BUILD_ARM_BAREMETAL=ON \
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
-DEXECUTORCH_ENABLE_LOGGING=ON \
${build_with_etdump_flags} \
-DFLATC_EXECUTABLE="$(which flatc)" \
-B"${et_build_dir}" \
"${et_root_dir}"

echo "[$(basename $0)] Configured CMAKE"

cmake --build ${et_build_dir} --parallel --target install --config ${build_type} --

set +x

echo "[$(basename $0)] Generated static libraries for ExecuTorch:"
find ${et_build_dir} -name "*.a" -exec ls -al {} \;
125 changes: 125 additions & 0 deletions backends/arm/scripts/build_executorch_runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#!/usr/bin/env bash
# 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.

set -eu

script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
et_root_dir=$(cd ${script_dir}/../../.. && pwd)
et_root_dir=$(realpath ${et_root_dir})
toolchain_cmake=${et_root_dir}/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake

pte_file=""
target="ethos-u55-128"
build_type="Release"
system_config=""
build_with_etdump=false
extra_build_flags=""
output_folder_set=false
output_folder="."
et_build_root="${et_root_dir}/arm_test"
ethosu_tools_dir=${et_root_dir}/examples/arm/ethos-u-scratch

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 " --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 " --system_config=<CONFIG> System configuration to select from the Vela configuration file (see vela.ini). Default: Ethos_U55_High_End_Embedded for EthosU55 targets, Ethos_U85_SYS_DRAM_Mid for EthosU85 targets."
echo " NOTE: If given, this option must match the given target. This option also sets timing adapter values customized for specific hardware, see ./executor_runner/CMakeLists.txt."
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 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}"
echo " --ethosu_tools_dir=<FOLDER> Path to your Ethos-U tools dir if you not using default: ${ethosu_tools_dir}"
exit 0
}

for arg in "$@"; do
case $arg in
-h|--help) help ;;
--pte=*) pte_file="${arg#*=}";;
--target=*) target="${arg#*=}";;
--build_type=*) build_type="${arg#*=}";;
--system_config=*) system_config="${arg#*=}";;
--etdump) build_with_etdump=true ;;
--extra_build_flags=*) extra_build_flags="${arg#*=}";;
--output=*) output_folder="${arg#*=}" ; output_folder_set=true ;;
--et_build_root=*) et_build_root="${arg#*=}";;
--ethosu_tools_dir=*) ethosu_tools_dir="${arg#*=}";;
*)
;;
esac
done

pte_file=$(realpath ${pte_file})
ethosu_tools_dir=$(realpath ${ethosu_tools_dir})
ethos_u_root_dir="$ethosu_tools_dir/ethos-u"
ethosu_tools_dir=$(realpath ${ethos_u_root_dir})

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

if [ "$output_folder_set" = false ] ; then
pte_folder=$(cd -- "$( dirname -- "${pte_file}" )" &> /dev/null && pwd)
pte_short_name=$(basename -- "${pte_file}" ".pte")
output_folder="$pte_folder/$pte_short_name"
fi

if [[ ${system_config} == "" ]]
then
system_config="Ethos_U55_High_End_Embedded"
if [[ ${target} =~ "ethos-u85" ]]
then
system_config="Ethos_U85_SYS_DRAM_Mid"
fi
fi

output_folder=$(realpath ${output_folder})

if [[ ${target} == *"ethos-u55"* ]]; then
target_cpu=cortex-m55
else
target_cpu=cortex-m85
fi
echo "--------------------------------------------------------------------------------"
echo "Build Arm Baremetal executor_runner for ${target} with ${pte_file} using ${system_config} to '${output_folder}/cmake-out'"
echo "--------------------------------------------------------------------------------"

cd ${et_root_dir}/examples/arm/executor_runner

build_with_etdump_flags=""
if [ "$build_with_etdump" = true ] ; then
echo "Building with etdump e.g. -DEXECUTORCH_ENABLE_EVENT_TRACER=ON"
build_with_etdump_flags=" -DEXECUTORCH_ENABLE_EVENT_TRACER=ON "
fi

mkdir -p "$output_folder"

cmake \
-DCMAKE_BUILD_TYPE=${build_type} \
-DCMAKE_TOOLCHAIN_FILE=${toolchain_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_with_etdump_flags} \
-DPYTHON_EXECUTABLE=$(which python3) \
-DSYSTEM_CONFIG=${system_config} \
${extra_build_flags} \
-B ${output_folder}/cmake-out

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

cmake --build ${output_folder}/cmake-out --parallel -- arm_executor_runner

echo "[${BASH_SOURCE[0]}] Generated baremetal elf file:"
find ${output_folder}/cmake-out -name "arm_executor_runner"
echo "executable_text: $(find ${output_folder}/cmake-out -name arm_executor_runner -exec arm-none-eabi-size {} \; | grep -v filename | awk '{print $1}') bytes"
echo "executable_data: $(find ${output_folder}/cmake-out -name arm_executor_runner -exec arm-none-eabi-size {} \; | grep -v filename | awk '{print $2}') bytes"
echo "executable_bss: $(find ${output_folder}/cmake-out -name arm_executor_runner -exec arm-none-eabi-size {} \; | grep -v filename | awk '{print $3}') bytes"
74 changes: 74 additions & 0 deletions backends/arm/scripts/build_portable_kernels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bash
# 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.

# Optional parameter:
# --build_type= "Release" | "Debug" | "RelWithDebInfo"
# --etdump build with devtools-etdump support

set -eu

script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
et_root_dir=$(cd ${script_dir}/../../.. && pwd)
et_root_dir=$(realpath ${et_root_dir})
toolchain_cmake=${script_dir}/../../../examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake
toolchain_cmake=$(realpath ${toolchain_cmake})


et_build_root="${et_root_dir}/arm_test"
build_type="Release"
portable_kernels="aten::_softmax.out"

help() {
echo "Usage: $(basename $0) [options]"
echo "Options:"
echo " --et_build_root=<FOLDER> Build output root folder to use, defaults to ${et_build_root}"
echo " --build_type=<TYPE> Build with Release, Debug or RelWithDebInfo, default is ${build_type}"
echo " --portable_kernels=<OPS> Comma separated list of portable (non delagated) kernels to include Default: ${portable_kernels}"
exit 0
}

for arg in "$@"; do
case $arg in
-h|--help) help ;;
--et_build_root=*) et_build_root="${arg#*=}";;
--build_type=*) build_type="${arg#*=}";;
--portable_kernels=*) portable_kernels="${arg#*=}";;
*)
;;
esac
done

et_build_dir=${et_build_root}/cmake-out

cd "${et_root_dir}"

echo "--------------------------------------------------------------------------------" ;
echo "Build ExecuTorch Libraries ${build_type} portable kernels: ${portable_kernels} into '${et_build_dir}'" ;
echo "--------------------------------------------------------------------------------"

if ! [[ $portable_kernels =~ ^((^|,)aten::[a-zA-Z0-9_]+\.[a-zA-Z0-9_]*out)*$ ]]; then
echo " ERROR: specified argument --portable_kernels=${portable_kernels}"
echo " is in the wrong format please use \"aten::<OP1>.out,aten::<OP2>.out,...\""
echo " e.g. \"aten::_softmax.out,aten::add.out\""
exit 1
fi

set -x

cmake \
-DCMAKE_INSTALL_PREFIX=${et_build_dir} \
-DCMAKE_BUILD_TYPE=${build_type} \
-DCMAKE_TOOLCHAIN_FILE="${toolchain_cmake}" \
-DEXECUTORCH_SELECT_OPS_LIST=${portable_kernels} \
-B"${et_build_dir}/examples/arm" \
"${et_root_dir}/examples/arm"

cmake --build "${et_build_dir}/examples/arm" --parallel --config ${build_type} --

set +x

echo "[$(basename $0)] Generated static libraries for ExecuTorch:"
find "${et_build_dir}/examples/arm" -name "*.a" -exec ls -al {} \;
Loading
Loading