Skip to content
Closed
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
11 changes: 8 additions & 3 deletions backends/arm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,20 @@ if(EXECUTORCH_BUILD_ARM_BAREMETAL OR EXECUTORCH_BUILD_ARM_ETHOSU_LINUX)

add_library(executorch_delegate_ethos_u STATIC ${_arm_backend_sources})
target_link_libraries(executorch_delegate_ethos_u PUBLIC executorch_core)
target_include_directories(
executorch_delegate_ethos_u PRIVATE ${_common_include_directories}
)

if(EXECUTORCH_BUILD_ARM_BAREMETAL)
target_sources(
executorch_delegate_ethos_u
PRIVATE ${EXECUTORCH_ROOT}/backends/arm/runtime/EthosUBackend_Cortex_M.cpp
)
set(DRIVER_ETHOSU_INCLUDE_DIR
set(_ethosu_core_driver_include
"${THIRD_PARTY_ROOT}/ethos-u-core-driver/include"
)
target_include_directories(
executorch_delegate_ethos_u PRIVATE ${DRIVER_ETHOSU_INCLUDE_DIR}
executorch_delegate_ethos_u PRIVATE ${_ethosu_core_driver_include}
)
target_link_libraries(executorch_delegate_ethos_u PUBLIC ethosu_core_driver)
elseif(EXECUTORCH_BUILD_ARM_ETHOSU_LINUX)
Expand Down Expand Up @@ -108,7 +111,9 @@ if(EXECUTORCH_BUILD_ARM_BAREMETAL OR EXECUTORCH_BUILD_ARM_ETHOSU_LINUX)
)
endif()

install(TARGETS executorch_delegate_ethos_u EXPORT ExecuTorchTargets)
if(NOT CMAKE_SKIP_INSTALL_RULES)
install(TARGETS executorch_delegate_ethos_u EXPORT ExecuTorchTargets)
endif()

endif()

Expand Down
53 changes: 29 additions & 24 deletions backends/arm/scripts/build_executor_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ 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})
runner_source_dir=${et_root_dir}/examples/arm/executor_runner
runner_source_dir=$(realpath ${runner_source_dir})
preset_file=${et_root_dir}/tools/cmake/preset/arm_baremetal.cmake
toolchain=arm-none-eabi-gcc
setup_path_script=${et_root_dir}/examples/arm/arm-scratch/setup_path.sh
_setup_msg="please refer to ${et_root_dir}/examples/arm/setup.sh to properly install necessary tools."
Expand Down Expand Up @@ -101,6 +104,9 @@ toolchain_cmake=$(realpath ${toolchain_cmake})

source ${setup_path_script}

[[ -f ${preset_file} ]] \
|| { echo "Missing ${preset_file}. ${_setup_msg}"; exit 1; }

if [[ ${pte_file} == "semihosting" ]]; then
pte_data="-DSEMIHOSTING=ON"
else
Expand All @@ -122,13 +128,9 @@ else
fi
fi
ethosu_tools_dir=$(realpath ${ethosu_tools_dir})
ethos_u_root_dir="$ethosu_tools_dir/ethos-u"
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})
ethos_u_root_dir=$(realpath ${ethos_u_root_dir})

if [[ ${system_config} == "" ]]
then
Expand Down Expand Up @@ -160,34 +162,37 @@ echo "--------------------------------------------------------------------------
echo "Build Arm ${toolchain/-gcc/} executor_runner for ${target} PTE: ${pte_file} using ${system_config} ${memory_mode} ${extra_build_flags} to '${output_folder}'"
echo "--------------------------------------------------------------------------------"

cd ${et_root_dir}/examples/arm/executor_runner

if [ "$bundleio" = true ] ; then
build_bundleio_flags=" -DET_BUNDLE_IO=ON "
fi

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

echo "Building with BundleIO/etdump/extra flags: ${build_bundleio_flags} ${build_with_etdump_flags} ${extra_build_flags}"
echo "Building with BundleIO/etdump/extra flags: ${build_bundleio_flags} ${build_with_etdump_flags} ${devtools_flags} ${extra_build_flags}"
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} \
-DETHOS_SDK_PATH:PATH=${ethos_u_root_dir} \
-DETHOSU_TARGET_NPU_CONFIG=${target} \
${pte_data} \
${build_bundleio_flags} \
${build_with_etdump_flags} \
-DPYTHON_EXECUTABLE=$(which python3) \
-DSYSTEM_CONFIG=${system_config} \
-DMEMORY_MODE=${memory_mode} \
-S ${runner_source_dir} \
-B ${output_folder} \
-DEXECUTORCH_ROOT=${et_root_dir} \
-DCMAKE_BUILD_TYPE=${build_type} \
-DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} \
-DTARGET_CPU=${target_cpu} \
-DETHOSU_TARGET_NPU_CONFIG=${target} \
-DEXECUTORCH_BUILD_PRESET_FILE=${preset_file} \
${pte_data} \
${build_bundleio_flags} \
${build_with_etdump_flags} \
${devtools_flags} \
-DSYSTEM_CONFIG=${system_config} \
-DMEMORY_MODE=${memory_mode} \
-DEXECUTORCH_SELECT_OPS_LIST="${select_ops_list}" \
${extra_build_flags} \
-B ${output_folder}
-DETHOS_SDK_PATH:PATH=${ethos_u_root_dir} \
${extra_build_flags}

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

Expand Down
2 changes: 1 addition & 1 deletion backends/arm/scripts/build_executorch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ parallel_jobs="$(get_parallel_jobs)"
if [[ ${is_linux_musl} -eq 1 ]]; then
cmake --build ${et_build_dir} -j"${parallel_jobs}" --target executorch_delegate_ethos_u executor_runner --config ${build_type} --
else
cmake --build ${et_build_dir} -j"${parallel_jobs}" --target install --config ${build_type} --
cmake --build ${et_build_dir} -j"${parallel_jobs}" --config ${build_type}
fi

set +x
Expand Down
6 changes: 6 additions & 0 deletions examples/arm/ethos_u_minimal_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@
"%%bash\n",
"# Ensure the arm-none-eabi-gcc toolchain and FVP:s are available on $PATH\n",
"source arm-scratch/setup_path.sh\n",
"# Ensure CMake resolves the ExecuTorch checkout root regardless of caller env\n",
"export EXECUTORCH_ROOT=$(cd ../.. && pwd)\n",
"\n",
"# Build executorch libraries cross-compiled for arm baremetal to executorch/cmake-out-arm\n",
"cmake --preset arm-baremetal \\\n",
Expand All @@ -202,6 +204,8 @@
"source": [
"%%bash \n",
"source arm-scratch/setup_path.sh\n",
"# Ensure CMake resolves the ExecuTorch checkout root regardless of caller env\n",
"export EXECUTORCH_ROOT=$(cd ../.. && pwd)\n",
"\n",
"# Build example executor runner application to examples/arm/ethos_u_minimal_example\n",
"cmake -DCMAKE_TOOLCHAIN_FILE=$(pwd)/ethos-u-setup/arm-none-eabi-gcc.cmake \\\n",
Expand Down Expand Up @@ -233,6 +237,8 @@
"source": [
"%%bash \n",
"source arm-scratch/setup_path.sh\n",
"# Ensure CMake resolves the ExecuTorch checkout root regardless of caller env\n",
"export EXECUTORCH_ROOT=$(cd ../.. && pwd)\n",
"\n",
"# Run the example\n",
"../../backends/arm/scripts/run_fvp.sh --elf=ethos_u_minimal_example/arm_executor_runner --target=ethos-u55-128"
Expand Down
Loading
Loading