Skip to content

Commit 4635ad0

Browse files
committed
Consolidating executor runners in CMake - xnnpack
Continuing the process of consolidating the executor runners to top level CMakeLists.txt file. Completing this process for the xnnpack backend. Change also updates the CI tests to not use the generic executor_runner and removes the specific xnn_executor_runner.
1 parent 543cdb3 commit 4635ad0

File tree

2 files changed

+18
-43
lines changed

2 files changed

+18
-43
lines changed

.ci/scripts/test_model.sh

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,22 @@ prepare_artifacts_upload() {
4949
}
5050

5151
build_cmake_executor_runner() {
52+
local backend_string_select="${1:-}"
5253
echo "Building executor_runner"
5354
rm -rf ${CMAKE_OUTPUT_DIR}
54-
cmake -DCMAKE_BUILD_TYPE=Debug \
55-
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
56-
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
57-
-B${CMAKE_OUTPUT_DIR} .
58-
55+
if [[ "$backend_string_select" == "XNNPACK"]]; then
56+
echo "Backend $backend_string_select selected"
57+
cmake -DCMAKE_BUILD_TYPE=Debug \
58+
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
59+
-DEXECUTORCH_BUILD_XNNPACK=ON \
60+
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
61+
-B${CMAKE_OUTPUT_DIR} .
62+
else
63+
cmake -DCMAKE_BUILD_TYPE=Debug \
64+
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
65+
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" \
66+
-B${CMAKE_OUTPUT_DIR} .
67+
fi
5968
cmake --build ${CMAKE_OUTPUT_DIR} -j4 --config Debug
6069
}
6170

@@ -111,19 +120,6 @@ test_model() {
111120
run_portable_executor_runner
112121
}
113122

114-
build_cmake_xnn_executor_runner() {
115-
echo "Building xnn_executor_runner"
116-
117-
(rm -rf ${CMAKE_OUTPUT_DIR} \
118-
&& mkdir ${CMAKE_OUTPUT_DIR} \
119-
&& cd ${CMAKE_OUTPUT_DIR} \
120-
&& retry cmake -DCMAKE_BUILD_TYPE=Release \
121-
-DEXECUTORCH_BUILD_XNNPACK=ON \
122-
-DPYTHON_EXECUTABLE="$PYTHON_EXECUTABLE" ..)
123-
124-
cmake --build ${CMAKE_OUTPUT_DIR} -j4
125-
}
126-
127123
test_model_with_xnnpack() {
128124
WITH_QUANTIZATION=$1
129125
WITH_DELEGATION=$2
@@ -148,12 +144,13 @@ test_model_with_xnnpack() {
148144

149145
# Run test model
150146
if [[ "${BUILD_TOOL}" == "buck2" ]]; then
147+
# TODO eventually buck should also use consolidated executor runners
151148
buck2 run //examples/xnnpack:xnn_executor_runner -- --model_path "${OUTPUT_MODEL_PATH}"
152149
elif [[ "${BUILD_TOOL}" == "cmake" ]]; then
153-
if [[ ! -f ${CMAKE_OUTPUT_DIR}/backends/xnnpack/xnn_executor_runner ]]; then
154-
build_cmake_xnn_executor_runner
150+
if [[ ! -f ${CMAKE_OUTPUT_DIR}/executor_runner ]]; then
151+
build_cmake_executor_runner("XNNPACK")
155152
fi
156-
./${CMAKE_OUTPUT_DIR}/backends/xnnpack/xnn_executor_runner --model_path "${OUTPUT_MODEL_PATH}"
153+
./${CMAKE_OUTPUT_DIR}/executor_runner --model_path "${OUTPUT_MODEL_PATH}"
157154
else
158155
echo "Invalid build tool ${BUILD_TOOL}. Only buck2 and cmake are supported atm"
159156
exit 1

backends/xnnpack/CMakeLists.txt

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,6 @@ target_include_directories(
114114
target_compile_options(xnnpack_backend PUBLIC ${_common_compile_options})
115115
target_link_options_shared_lib(xnnpack_backend)
116116

117-
if(EXECUTORCH_BUILD_KERNELS_OPTIMIZED)
118-
list(APPEND xnn_executor_runner_libs optimized_native_cpu_ops_lib)
119-
else()
120-
list(APPEND xnn_executor_runner_libs portable_ops_lib)
121-
endif()
122-
123-
if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
124-
list(APPEND xnn_executor_runner_libs $<LINK_LIBRARY:WHOLE_ARCHIVE,custom_ops>)
125-
endif()
126-
127-
if(EXECUTORCH_BUILD_KERNELS_QUANTIZED)
128-
list(APPEND xnn_executor_runner_libs quantized_ops_lib)
129-
endif()
130-
131-
list(APPEND xnn_executor_runner_libs xnnpack_backend executorch)
132-
133117
# ios can only build library but not binary
134118
if(NOT CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$")
135119
#
@@ -139,11 +123,6 @@ if(NOT CMAKE_TOOLCHAIN_FILE MATCHES ".*(iOS|ios\.toolchain)\.cmake$")
139123
list(TRANSFORM _xnn_executor_runner__srcs PREPEND "${EXECUTORCH_ROOT}/")
140124
add_executable(xnn_executor_runner ${_xnn_executor_runner__srcs})
141125

142-
if(EXECUTORCH_ENABLE_EVENT_TRACER)
143-
list(APPEND xnn_executor_runner_libs etdump)
144-
endif()
145-
146-
target_link_libraries(xnn_executor_runner gflags ${xnn_executor_runner_libs})
147126
target_compile_options(xnn_executor_runner PUBLIC ${_common_compile_options})
148127
if(EXECUTORCH_BUILD_PTHREADPOOL)
149128
target_link_libraries(xnn_executor_runner extension_threadpool pthreadpool)
@@ -153,7 +132,6 @@ endif()
153132

154133
install(
155134
TARGETS xnnpack_backend
156-
DESTINATION lib
157135
INCLUDES
158136
DESTINATION ${_common_include_directories}
159137
)

0 commit comments

Comments
 (0)