Skip to content

[easy] cmake-format extension/training/CMakeLists.txt #12451

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 15, 2025
Merged
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
20 changes: 11 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,12 @@ set(CMAKE_SKIP_BUILD_RPATH OFF)
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
# Automatically add all linked folders that are NOT in the build directory to
# the rpath (per library?)
# TODO: Doesn't work for us right now because we are
# not installing .so's into the correct locations. For example we have
# libcustom_ops_aot_lib.so depending on _portable_lib.so, which was eventually
# put under <site-packages>/executorch/extension/pybindings/ but this rpath is
# not automatically added because at build time it seems `portable_lib` is being
#
# TODO: Doesn't work for us right now because we are not installing .so's into
# the correct locations. For example we have libcustom_ops_aot_lib.so depending
# on _portable_lib.so, which was eventually put under
# <site-packages>/executorch/extension/pybindings/ but this rpath is not
# automatically added because at build time it seems `portable_lib` is being
# built under the same directory, so no extra rpath is being added. To properly
# fix this we need to install `portable_lib` into the correct path.
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
Expand Down Expand Up @@ -321,8 +322,9 @@ if(EXECUTORCH_USE_CPP_CODE_COVERAGE)
" -fprofile-instr-generate -fcoverage-mapping"
)
else()
message(FATAL_ERROR
"Code coverage for compiler ${CMAKE_CXX_COMPILER_ID} is unsupported"
message(
FATAL_ERROR
"Code coverage for compiler ${CMAKE_CXX_COMPILER_ID} is unsupported"
)
endif()
endif()
Expand Down Expand Up @@ -633,8 +635,8 @@ if(EXECUTORCH_BUILD_PYBIND)
endif()

if(EXECUTORCH_BUILD_XNNPACK)
# need to explicitly specify XNNPACK and xnnpack-microkernels-prod here otherwise
# uses XNNPACK and microkernel-prod symbols from libtorch_cpu
# need to explicitly specify XNNPACK and xnnpack-microkernels-prod here
# otherwise uses XNNPACK and microkernel-prod symbols from libtorch_cpu
list(APPEND _dep_libs xnnpack_backend XNNPACK xnnpack-microkernels-prod)
endif()

Expand Down
53 changes: 32 additions & 21 deletions extension/training/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,47 +25,58 @@ target_include_directories(

target_include_directories(extension_training PUBLIC ${EXECUTORCH_ROOT}/..)
target_compile_options(extension_training PUBLIC ${_common_compile_options})
target_link_libraries(extension_training executorch_core kernels_util_all_deps
extension_data_loader extension_module_static extension_tensor extension_flat_tensor )

target_link_libraries(
extension_training
executorch_core
kernels_util_all_deps
extension_data_loader
extension_module_static
extension_tensor
extension_flat_tensor
)

list(TRANSFORM _train_xor__srcs PREPEND "${EXECUTORCH_ROOT}/")
add_executable(train_xor ${_train_xor__srcs})
target_include_directories(
train_xor PUBLIC ${_common_include_directories}
)
target_include_directories(train_xor PUBLIC ${_common_include_directories})
target_link_libraries(
train_xor gflags executorch_core portable_ops_lib extension_tensor
extension_training program_schema
train_xor
gflags
executorch_core
portable_ops_lib
extension_tensor
extension_training
program_schema
)
target_compile_options(train_xor PUBLIC ${_common_compile_options})

if(EXECUTORCH_BUILD_PYBIND)
# Pybind library.
set(_pybind_training_dep_libs
${TORCH_PYTHON_LIBRARY}
etdump
executorch
util
torch
extension_training
set(_pybind_training_dep_libs ${TORCH_PYTHON_LIBRARY} etdump executorch util
torch extension_training
)

if(EXECUTORCH_BUILD_XNNPACK)
# need to explicitly specify XNNPACK and xnnpack-microkernels-prod
# here otherwise uses XNNPACK and microkernel-prod symbols from libtorch_cpu
list(APPEND _pybind_training_dep_libs xnnpack_backend XNNPACK xnnpack-microkernels-prod)
# need to explicitly specify XNNPACK and xnnpack-microkernels-prod here
# otherwise uses XNNPACK and microkernel-prod symbols from libtorch_cpu
list(APPEND _pybind_training_dep_libs xnnpack_backend XNNPACK
xnnpack-microkernels-prod
)
endif()

# pybind training
pybind11_add_module(_training_lib SHARED ${CMAKE_CURRENT_SOURCE_DIR}/pybindings/_training_lib.cpp)
pybind11_add_module(
_training_lib SHARED
${CMAKE_CURRENT_SOURCE_DIR}/pybindings/_training_lib.cpp
)

target_include_directories(_training_lib PRIVATE ${TORCH_INCLUDE_DIRS})
target_compile_options(_training_lib PUBLIC -Wno-deprecated-declarations -fPIC -frtti -fexceptions)
target_compile_options(
_training_lib PUBLIC -Wno-deprecated-declarations -fPIC -frtti -fexceptions
)
target_link_libraries(_training_lib PRIVATE ${_pybind_training_dep_libs})

install(TARGETS _training_lib
LIBRARY DESTINATION executorch/extension/training/pybindings
LIBRARY DESTINATION executorch/extension/training/pybindings
)
endif()

Expand Down
Loading