Skip to content

Commit 611092d

Browse files
authored
Enforce required cmake flags as explicit requirements (#11457)
### Summary The build file currently turns on a bunch of implicitly dependent flags, perhaps unnecessarily. Let's make these dependencies explicit now. For example, previously if `EXECUTORCH_BUILD_EXTENSION_TRAINING` was turned on, it would then turn on its own set of dependencies. This is good from a developer experience point of view because users would need to just turn on one flag. However, from a build point of view, it makes it harder to maintain and understand what flags are conflicting with one another. Now, if you want to build the training extension, you will have to explicitly turn on the required flags. However, with our build presets — most developers should not have to do to this! I have created a follow up ticket to actually comb through the existing flags and trim the fat if necessary: #11458 ### Test plan CI cc @larryliu0820
1 parent 8f05c35 commit 611092d

File tree

12 files changed

+81
-36
lines changed

12 files changed

+81
-36
lines changed

.ci/scripts/build-qnn-sdk.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ set_up_aot() {
3232
-DQNN_SDK_ROOT=${QNN_SDK_ROOT} \
3333
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
3434
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
35+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
36+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
3537
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
3638
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
3739
-DPYTHON_EXECUTABLE=python3

.ci/scripts/test_llama_torchao_lowbit.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ cmake -DPYTHON_EXECUTABLE=python \
3030
-DCMAKE_BUILD_TYPE=Release \
3131
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
3232
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
33+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
3334
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
3435
-DEXECUTORCH_BUILD_XNNPACK=OFF \
3536
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \

.ci/scripts/test_llava.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ EXECUTORCH_COMMON_CMAKE_ARGS=" \
3737
-DEXECUTORCH_ENABLE_LOGGING=ON \
3838
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3939
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
40+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
4041
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
4142
-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
4243
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \

.ci/scripts/test_phi_3_mini.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ cmake_install_executorch_libraries() {
2727
-DEXECUTORCH_ENABLE_LOGGING=1 \
2828
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
2929
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
30+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
3031
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
3132
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
3233
-DEXECUTORCH_BUILD_XNNPACK=ON \

.github/workflows/trunk.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ jobs:
552552
-DEXECUTORCH_ENABLE_LOGGING=1 \
553553
-DCMAKE_BUILD_TYPE=Release \
554554
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
555+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
555556
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
556557
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
557558
-DEXECUTORCH_BUILD_XNNPACK=ON \

CMakeLists.txt

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -152,37 +152,11 @@ else()
152152
endif()
153153

154154
if(EXECUTORCH_BUILD_TESTS)
155-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
156155
include(CTest)
157156
endif()
158157

159158
add_subdirectory(third-party)
160159

161-
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
162-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
163-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
164-
set(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
165-
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
166-
endif()
167-
168-
if(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR)
169-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
170-
endif()
171-
172-
if(EXECUTORCH_BUILD_EXTENSION_MODULE)
173-
set(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
174-
set(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
175-
endif()
176-
177-
if(EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT)
178-
set(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
179-
set(EXECUTORCH_BUILD_KERNELS_CUSTOM ON)
180-
endif()
181-
182-
if(EXECUTORCH_BUILD_KERNELS_CUSTOM)
183-
set(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)
184-
endif()
185-
186160
if(NOT DEFINED FXDIV_SOURCE_DIR)
187161
set(ORIGINAL_CMAKE_POSITION_INDEPENDENT_CODE_FLAG
188162
${CMAKE_POSITION_INDEPENDENT_CODE}
@@ -336,7 +310,7 @@ if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
336310
" -fprofile-instr-generate -fcoverage-mapping"
337311
)
338312
else()
339-
message(ERROR
313+
message(FATAL_ERROR
340314
"Code coverage for compiler ${CMAKE_CXX_COMPILER_ID} is unsupported"
341315
)
342316
endif()

backends/qualcomm/scripts/build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ if [ "$BUILD_AARCH64" = true ]; then
8181
-DEXECUTORCH_BUILD_QNN=ON \
8282
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
8383
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
84+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
85+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
8486
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
8587
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
8688
-DQNN_SDK_ROOT=$QNN_SDK_ROOT \
@@ -127,6 +129,8 @@ if [ "$BUILD_X86_64" = true ]; then
127129
-DEXECUTORCH_BUILD_QNN=ON \
128130
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
129131
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
132+
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
133+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
130134
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
131135
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
132136
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \

examples/models/phi-3-mini/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED True)
2121
set(CMAKE_BUILD_TYPE Release)
2222

2323
# Set options for executorch build.
24-
option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER "" ON)
2524
option(EXECUTORCH_BUILD_EXTENSION_MODULE "" ON)
25+
option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER "" ON)
26+
option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR "" ON)
2627
option(EXECUTORCH_BUILD_EXTENSION_TENSOR "" ON)
2728
option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED "" ON)
2829
option(EXECUTORCH_BUILD_XNNPACK "" ON)

scripts/build_android_library.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ build_android_native_library() {
4747
-DEXECUTORCH_BUILD_XNNPACK=ON \
4848
-DEXECUTORCH_XNNPACK_SHARED_WORKSPACE=ON \
4949
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
50+
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
5051
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
5152
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
5253
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \

tools/cmake/preset/apple_common.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ set_overridable_option(EXECUTORCH_XNNPACK_SHARED_WORKSPACE ON)
2222
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_APPLE ON)
2323
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
2424
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
25+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
2526
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
2627
set_overridable_option(EXECUTORCH_BUILD_KERNELS_CUSTOM ON)
2728
set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)

0 commit comments

Comments
 (0)