mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
This change fixes the RUNPATH of installed c++ tests so that the linker can find the shared libraries they depend on. For example, currently: ```bash venv/lib/python3.10/site-packages/torch $ ./bin/test_lazy ./bin/test_lazy: error while loading shared libraries: libtorch.so: cannot open shared object file: No such file or directory ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/136627 Approved by: https://github.com/malfet
84 lines
3.2 KiB
CMake
84 lines
3.2 KiB
CMake
set(TENSOREXPR_TEST_ROOT ${TORCH_ROOT}/test/cpp/tensorexpr)
|
|
|
|
set(TENSOREXPR_TEST_SRCS
|
|
${TENSOREXPR_TEST_ROOT}/test_approx.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_aten.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_boundsinference.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_conv.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_cpp_codegen.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_dynamic_shapes.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_expr.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_external_calls.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_graph_opt.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_ir_printer.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_ir_verifier.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_kernel.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_loopnest.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_memdependency.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_ops.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_quantization.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_memplanning.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_reductions.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_registerizer.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_simplify.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_te_fuser_pass.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_type.cpp
|
|
${TENSOREXPR_TEST_ROOT}/test_type_specializations.cpp
|
|
)
|
|
|
|
if(USE_CUDA)
|
|
list(APPEND TENSOREXPR_TEST_SRCS ${TENSOREXPR_TEST_ROOT}/test_cuda.cpp)
|
|
endif()
|
|
|
|
if(USE_LLVM AND LLVM_FOUND)
|
|
list(APPEND TENSOREXPR_TEST_SRCS ${TENSOREXPR_TEST_ROOT}/test_llvm.cpp)
|
|
endif()
|
|
|
|
add_executable(test_tensorexpr
|
|
${TORCH_ROOT}/test/cpp/common/main.cpp
|
|
${TENSOREXPR_TEST_ROOT}/padded_buffer.cpp
|
|
${TENSOREXPR_TEST_SRCS})
|
|
|
|
target_link_libraries(test_tensorexpr PRIVATE torch gtest)
|
|
target_include_directories(test_tensorexpr PRIVATE ${ATen_CPU_INCLUDE})
|
|
target_compile_definitions(test_tensorexpr PRIVATE USE_GTEST)
|
|
|
|
add_executable(tutorial_tensorexpr ${TENSOREXPR_TEST_ROOT}/tutorial.cpp)
|
|
target_link_libraries(tutorial_tensorexpr PRIVATE torch)
|
|
target_include_directories(tutorial_tensorexpr PRIVATE ${ATen_CPU_INCLUDE})
|
|
|
|
# The test case depends on the xnnpack header which in turn depends on the
|
|
# pthreadpool header. For some build environment we need add the dependency
|
|
# explicitly.
|
|
if(USE_PTHREADPOOL)
|
|
target_link_libraries(test_tensorexpr PRIVATE pthreadpool_interface)
|
|
endif()
|
|
if(USE_CUDA)
|
|
target_compile_definitions(test_tensorexpr PRIVATE USE_CUDA)
|
|
target_compile_definitions(tutorial_tensorexpr PRIVATE USE_CUDA)
|
|
elseif(USE_ROCM)
|
|
target_link_libraries(test_tensorexpr PRIVATE
|
|
hiprtc::hiprtc
|
|
hip::amdhip64
|
|
${TORCH_CUDA_LIBRARIES})
|
|
target_compile_definitions(test_tensorexpr PRIVATE USE_ROCM)
|
|
|
|
target_link_libraries(tutorial_tensorexpr PRIVATE
|
|
hiprtc::hiprtc
|
|
hip::amdhip64
|
|
${TORCH_CUDA_LIBRARIES})
|
|
target_compile_definitions(tutorial_tensorexpr PRIVATE USE_ROCM)
|
|
endif()
|
|
|
|
if(INSTALL_TEST)
|
|
set_target_properties(test_tensorexpr PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${_rpath_portable_origin}/../lib")
|
|
install(TARGETS test_tensorexpr DESTINATION bin)
|
|
set_target_properties(tutorial_tensorexpr PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${_rpath_portable_origin}/../lib")
|
|
install(TARGETS tutorial_tensorexpr DESTINATION bin)
|
|
# Install PDB files for MSVC builds
|
|
if(MSVC AND BUILD_SHARED_LIBS)
|
|
install(FILES $<TARGET_PDB_FILE:test_tensorexpr> DESTINATION bin OPTIONAL)
|
|
install(FILES $<TARGET_PDB_FILE:tutorial_tensorexpr> DESTINATION bin OPTIONAL)
|
|
endif()
|
|
endif()
|