Skip to content

Commit 09bcc32

Browse files
authored
Arm backend: Avoid Ethos-U SDK re-downloads (pytorch#21970)
The standalone runner path unconditionally re-downloaded the SDK. Instead, prefer to re-use the SDK from ETHOS_SDK_PATH if it exists. Additionally, fix use of deprecated OLD cmake policy of CMP0169. cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani
1 parent 92079a2 commit 09bcc32

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

‎backends/arm/CMakeLists.txt‎

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ if(NOT EXECUTORCH_ROOT)
1313
endif()
1414

1515
include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake)
16-
17-
if(POLICY CMP0169)
18-
# Allow FetchContent_Populate to be used for source-only fetch
19-
cmake_policy(SET CMP0169 OLD)
20-
endif()
16+
include(${EXECUTORCH_ROOT}/backends/arm/scripts/corstone_utils.cmake)
17+
include(${EXECUTORCH_ROOT}/backends/arm/cmake/ArmEthosUSDK.cmake)
2118

2219
set(_common_include_directories
2320
${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
@@ -43,7 +40,13 @@ set(ETHOS_SDK_PATH
4340
"${EXECUTORCH_ROOT}/examples/arm/arm-scratch/ethos-u"
4441
CACHE PATH "Path to Ethos-U bare metal driver/env"
4542
)
46-
option(FETCH_ETHOS_U_CONTENT "Fetch ethos_u dependencies" ON)
43+
# Set default value of FETCH_ETHOS_U_CONTENT depending on whether ethos sdk is
44+
# available in $ETHOS_SDK_PATH.
45+
arm_ethos_u_default_fetch("${ETHOS_SDK_PATH}" _fetch_ethos_u_default)
46+
option(FETCH_ETHOS_U_CONTENT
47+
"Fetch ethos_u dependencies instead of relying on pre-downloads"
48+
${_fetch_ethos_u_default}
49+
)
4750

4851
if(EXECUTORCH_BUILD_ARM_BAREMETAL AND EXECUTORCH_BUILD_ARM_ETHOSU_LINUX)
4952
message(
@@ -75,10 +78,9 @@ if(EXECUTORCH_BUILD_ARM_BAREMETAL OR EXECUTORCH_BUILD_ARM_ETHOSU_LINUX)
7578
executorch_delegate_ethos_u
7679
PRIVATE ${EXECUTORCH_ROOT}/backends/arm/runtime/EthosUBackend_Cortex_M.cpp
7780
)
78-
include(${EXECUTORCH_ROOT}/backends/arm/scripts/corstone_utils.cmake)
79-
if(FETCH_ETHOS_U_CONTENT)
80-
fetch_ethos_u_content(${ETHOS_SDK_PATH} ${EXECUTORCH_ROOT})
81-
endif()
81+
arm_ensure_ethos_u_content(
82+
"${ETHOS_SDK_PATH}" "${EXECUTORCH_ROOT}" ${FETCH_ETHOS_U_CONTENT}
83+
)
8284
set(DRIVER_ETHOSU_INCLUDE_DIR
8385
"${ETHOS_SDK_PATH}/core_software/core_driver/include"
8486
)
@@ -108,11 +110,11 @@ if(EXECUTORCH_BUILD_ARM_BAREMETAL OR EXECUTORCH_BUILD_ARM_ETHOSU_LINUX)
108110
GIT_REPOSITORY ${ETHOSU_LINUX_DRIVER_GIT_REPO}
109111
GIT_TAG ${ETHOSU_LINUX_DRIVER_GIT_TAG}
110112
GIT_SHALLOW TRUE
113+
# Point FetchContent at a nonexistent source subdirectory, tricking it
114+
# into downloading the sources without adding the project to the build.
115+
SOURCE_SUBDIR none
111116
)
112-
FetchContent_GetProperties(ethosu_linux_driver_src)
113-
if(NOT ethosu_linux_driver_src_POPULATED)
114-
FetchContent_Populate(ethosu_linux_driver_src)
115-
endif()
117+
FetchContent_MakeAvailable(ethosu_linux_driver_src)
116118
set(ETHOSU_LINUX_DRIVER_SOURCE_DIR ${ethosu_linux_driver_src_SOURCE_DIR})
117119
endif()
118120

0 commit comments

Comments
 (0)