mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
Fixes https://github.com/pytorch/pytorch/issues/74949, which reports that torch.config can't respect USE_MKLDNN flag. Pull Request resolved: https://github.com/pytorch/pytorch/pull/75001 Approved by: https://github.com/malfet
58 lines
2.2 KiB
CMake
58 lines
2.2 KiB
CMake
file(GLOB Detectron_CPU_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
|
|
file(GLOB Detectron_GPU_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.cu)
|
|
file(GLOB_RECURSE Detectron_HIP_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.hip)
|
|
|
|
if(BUILD_CAFFE2_OPS)
|
|
if(USE_OPENMP AND OPENMP_FOUND)
|
|
Set(OpenMP_link ${OpenMP_CXX_LIBRARIES})
|
|
endif()
|
|
|
|
# Note(ilijar): Since Detectron ops currently have no
|
|
# CPU implementation, we only build GPU ops for now.
|
|
if(USE_CUDA)
|
|
add_library(
|
|
caffe2_detectron_ops_gpu SHARED
|
|
${Detectron_CPU_SRCS}
|
|
${Detectron_GPU_SRCS})
|
|
|
|
torch_set_target_props(caffe2_detectron_ops_gpu)
|
|
target_link_libraries(caffe2_detectron_ops_gpu PRIVATE torch ${OpenMP_link})
|
|
if(USE_MKLDNN)
|
|
target_link_libraries(caffe2_detectron_ops_gpu PRIVATE caffe2::mkldnn)
|
|
endif()
|
|
install(TARGETS caffe2_detectron_ops_gpu DESTINATION lib)
|
|
if(MSVC)
|
|
install(FILES $<TARGET_PDB_FILE:caffe2_detectron_ops_gpu> DESTINATION lib OPTIONAL)
|
|
endif()
|
|
elseif(USE_ROCM)
|
|
hip_include_directories(${Caffe2_HIP_INCLUDES})
|
|
set_source_files_properties(${Detectron_HIP_SRCS} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)
|
|
HIP_ADD_LIBRARY(
|
|
caffe2_detectron_ops_hip SHARED
|
|
${Detectron_CPU_SRCS}
|
|
${Detectron_HIP_SRCS})
|
|
torch_set_target_props(caffe2_detectron_ops_hip)
|
|
target_compile_options(caffe2_detectron_ops_hip PRIVATE ${HIP_CXX_FLAGS})
|
|
if(USE_MKLDNN)
|
|
target_link_libraries(caffe2_detectron_ops_hip PRIVATE caffe2::mkldnn)
|
|
endif()
|
|
target_link_libraries(caffe2_detectron_ops_hip PRIVATE torch)
|
|
install(TARGETS caffe2_detectron_ops_hip DESTINATION lib)
|
|
elseif(NOT IOS_PLATFORM)
|
|
add_library(caffe2_detectron_ops SHARED ${Detectron_CPU_SRCS})
|
|
if(HAVE_SOVERSION)
|
|
set_target_properties(caffe2_detectron_ops PROPERTIES
|
|
VERSION ${TORCH_VERSION} SOVERSION ${TORCH_SOVERSION})
|
|
endif()
|
|
torch_set_target_props(caffe2_detectron_ops)
|
|
target_link_libraries(caffe2_detectron_ops PRIVATE torch ${OpenMP_link})
|
|
if(USE_MKLDNN)
|
|
target_link_libraries(caffe2_detectron_ops PRIVATE caffe2::mkldnn)
|
|
endif()
|
|
install(TARGETS caffe2_detectron_ops DESTINATION lib)
|
|
if(MSVC)
|
|
install(FILES $<TARGET_PDB_FILE:caffe2_detectron_ops> DESTINATION lib OPTIONAL)
|
|
endif()
|
|
endif()
|
|
endif()
|