Skip to content

Commit 2b12e69

Browse files
Gate training pybind build behind flag
Differential Revision: D75079436 Pull Request resolved: #11001
1 parent f5578a2 commit 2b12e69

File tree

3 files changed

+28
-26
lines changed

3 files changed

+28
-26
lines changed

CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ add_library(executorch_core ${_executorch_core__srcs})
362362
add_library(executorch_no_prim_ops ALIAS executorch_core)
363363

364364
target_link_libraries(executorch_core PRIVATE program_schema)
365+
if(ANDROID)
366+
target_link_libraries(executorch_core PUBLIC log)
367+
endif()
365368
if(EXECUTORCH_USE_DL)
366369
# Check if dl exists for this toolchain and only then link it.
367370
find_library(DL_LIBRARY_EXISTS NAMES dl)
@@ -653,10 +656,6 @@ if(EXECUTORCH_BUILD_PYBIND)
653656
install(TARGETS portable_lib
654657
LIBRARY DESTINATION executorch/extension/pybindings
655658
)
656-
657-
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)
658-
659-
endif()
660659
endif()
661660

662661
if(EXECUTORCH_BUILD_EXTENSION_TRAINING)

extension/training/CMakeLists.txt

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,34 @@ train_xor gflags executorch_core portable_ops_lib extension_tensor
4040
)
4141
target_compile_options(train_xor PUBLIC ${_common_compile_options})
4242

43-
# Pybind library.
44-
set(_pybind_training_dep_libs
45-
${TORCH_PYTHON_LIBRARY}
46-
etdump
47-
executorch
48-
util
49-
torch
50-
extension_training
51-
)
43+
if(EXECUTORCH_BUILD_PYBIND)
44+
# Pybind library.
45+
set(_pybind_training_dep_libs
46+
${TORCH_PYTHON_LIBRARY}
47+
etdump
48+
executorch
49+
util
50+
torch
51+
extension_training
52+
)
5253

53-
if(EXECUTORCH_BUILD_XNNPACK)
54-
# need to explicitly specify XNNPACK and microkernels-prod
55-
# here otherwise uses XNNPACK and microkernel-prod symbols from libtorch_cpu
56-
list(APPEND _pybind_training_dep_libs xnnpack_backend XNNPACK microkernels-prod)
57-
endif()
54+
if(EXECUTORCH_BUILD_XNNPACK)
55+
# need to explicitly specify XNNPACK and microkernels-prod
56+
# here otherwise uses XNNPACK and microkernel-prod symbols from libtorch_cpu
57+
list(APPEND _pybind_training_dep_libs xnnpack_backend XNNPACK microkernels-prod)
58+
endif()
5859

59-
# pybind training
60-
pybind11_add_module(_training_lib SHARED ${CMAKE_CURRENT_SOURCE_DIR}/pybindings/_training_lib.cpp)
60+
# pybind training
61+
pybind11_add_module(_training_lib SHARED ${CMAKE_CURRENT_SOURCE_DIR}/pybindings/_training_lib.cpp)
6162

62-
target_include_directories(_training_lib PRIVATE ${TORCH_INCLUDE_DIRS})
63-
target_compile_options(_training_lib PUBLIC -Wno-deprecated-declarations -fPIC -frtti -fexceptions)
64-
target_link_libraries(_training_lib PRIVATE ${_pybind_training_dep_libs})
63+
target_include_directories(_training_lib PRIVATE ${TORCH_INCLUDE_DIRS})
64+
target_compile_options(_training_lib PUBLIC -Wno-deprecated-declarations -fPIC -frtti -fexceptions)
65+
target_link_libraries(_training_lib PRIVATE ${_pybind_training_dep_libs})
6566

66-
install(TARGETS _training_lib
67-
LIBRARY DESTINATION executorch/extension/training/pybindings
68-
)
67+
install(TARGETS _training_lib
68+
LIBRARY DESTINATION executorch/extension/training/pybindings
69+
)
70+
endif()
6971

7072
# Install libraries
7173
install(

scripts/build_android_library.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ build_android_native_library() {
5050
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
5151
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
5252
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
53+
-DEXECUTORCH_BUILD_EXTENSION_TRAINING=ON \
5354
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
5455
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
5556
-DEXECUTORCH_BUILD_KERNELS_CUSTOM="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \

0 commit comments

Comments
 (0)