Skip to content
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

Fix multiple find_package(Torch) calls #8407

Merged
merged 3 commits into from
Feb 12, 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
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,9 @@ if(EXECUTORCH_BUILD_PYBIND)
endif()

# find pytorch lib, to allow pybind to take at::Tensor as input/output
find_package(Torch CONFIG REQUIRED)
if(NOT TARGET torch)
find_package(Torch CONFIG REQUIRED)
endif()
find_library(
TORCH_PYTHON_LIBRARY torch_python PATHS "${TORCH_INSTALL_PREFIX}/lib"
)
Expand Down
4 changes: 3 additions & 1 deletion build/Codegen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ function(gen_custom_ops_aot_lib)
${_out_dir}/CustomOpsNativeFunctions.h "${GEN_KERNEL_SOURCES}"
)
# Find `Torch`.
find_package(Torch REQUIRED)
if(NOT TARGET torch)
find_package(Torch REQUIRED)
endif()
# This lib uses ATen lib, so we explicitly enable rtti and exceptions.
target_compile_options(${GEN_LIB_NAME} PRIVATE -frtti -fexceptions)
target_compile_definitions(${GEN_LIB_NAME} PRIVATE USE_ATEN_LIB=1)
Expand Down
4 changes: 3 additions & 1 deletion extension/llm/custom_ops/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ install(TARGETS custom_ops DESTINATION lib)

if(EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT)
# Add a AOT library
find_package(Torch CONFIG REQUIRED)
if(NOT TARGET torch)
find_package(Torch CONFIG REQUIRED)
endif()
add_library(
custom_ops_aot_lib SHARED
${_custom_ops__srcs}
Expand Down
Loading