mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
Formatting cmake (to lowercase without space for if/elseif/else/endif) (#35521)
Summary:
Running commands:
```bash
shopt -s globstar
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i CMakeLists.txt
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i caffe2/**/CMakeLists.txt
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i torch/**/CMakeLists.txt
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i c10/**/CMakeLists.txt
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i cmake/**/*.cmake
sed -e 's/IF (/if(/g' -e 's/IF(/if(/g' -e 's/if (/if(/g' -e 's/ELSE (/else(/g' -e 's/ELSE(/else(/g' -e 's/else (/else(/g' -e 's/ENDif(/endif(/g' -e 's/ELSEif(/elseif(/g' -i cmake/**/*.cmake.in
```
We may further convert all the commands into lowercase according to the following issue: 77543bde41
.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/35521
Differential Revision: D20704382
Pulled By: malfet
fbshipit-source-id: 42186b9b1660c34428ab7ceb8d3f7a0ced5d2e80
This commit is contained in:
committed by
Facebook GitHub Bot
parent
04a3345335
commit
45c9ed825a
@ -40,20 +40,20 @@ add_library(c10 ${C10_SRCS} ${C10_HEADERS})
|
|||||||
# If building shared library, set dllimport/dllexport proper.
|
# If building shared library, set dllimport/dllexport proper.
|
||||||
target_compile_options(c10 PRIVATE "-DC10_BUILD_MAIN_LIB")
|
target_compile_options(c10 PRIVATE "-DC10_BUILD_MAIN_LIB")
|
||||||
# Enable hidden visibility if compiler supports it.
|
# Enable hidden visibility if compiler supports it.
|
||||||
if (${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
|
if(${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
|
||||||
target_compile_options(c10 PRIVATE "-fvisibility=hidden")
|
target_compile_options(c10 PRIVATE "-fvisibility=hidden")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ---[ Dependency of c10
|
# ---[ Dependency of c10
|
||||||
if (${USE_GFLAGS})
|
if(${USE_GFLAGS})
|
||||||
target_link_libraries(c10 PUBLIC gflags)
|
target_link_libraries(c10 PUBLIC gflags)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (${USE_GLOG})
|
if(${USE_GLOG})
|
||||||
target_link_libraries(c10 PUBLIC glog::glog)
|
target_link_libraries(c10 PUBLIC glog::glog)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USE_NUMA)
|
if(USE_NUMA)
|
||||||
message(STATUS "NUMA paths:")
|
message(STATUS "NUMA paths:")
|
||||||
message(STATUS ${Numa_INCLUDE_DIR})
|
message(STATUS ${Numa_INCLUDE_DIR})
|
||||||
message(STATUS ${Numa_LIBRARIES})
|
message(STATUS ${Numa_LIBRARIES})
|
||||||
@ -63,7 +63,7 @@ else()
|
|||||||
message(STATUS "don't use NUMA")
|
message(STATUS "don't use NUMA")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (ANDROID)
|
if(ANDROID)
|
||||||
target_link_libraries(c10 PRIVATE log)
|
target_link_libraries(c10 PRIVATE log)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -97,6 +97,6 @@ install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
|||||||
install(FILES ${CMAKE_BINARY_DIR}/c10/macros/cmake_macros.h
|
install(FILES ${CMAKE_BINARY_DIR}/c10/macros/cmake_macros.h
|
||||||
DESTINATION include/c10/macros)
|
DESTINATION include/c10/macros)
|
||||||
|
|
||||||
if (MSVC AND C10_BUILD_SHARED_LIBS)
|
if(MSVC AND C10_BUILD_SHARED_LIBS)
|
||||||
install(FILES $<TARGET_PDB_FILE:c10> DESTINATION lib OPTIONAL)
|
install(FILES $<TARGET_PDB_FILE:c10> DESTINATION lib OPTIONAL)
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
# ---[ Benchmark binaries.
|
# ---[ Benchmark binaries.
|
||||||
|
|
||||||
file(GLOB_RECURSE C10_ALL_BENCH_FILES *.cpp)
|
file(GLOB_RECURSE C10_ALL_BENCH_FILES *.cpp)
|
||||||
if (BUILD_TEST)
|
if(BUILD_TEST)
|
||||||
foreach(bench_src ${C10_ALL_BENCH_FILES})
|
foreach(bench_src ${C10_ALL_BENCH_FILES})
|
||||||
get_filename_component(bench_file_name ${bench_src} NAME_WE)
|
get_filename_component(bench_file_name ${bench_src} NAME_WE)
|
||||||
set(bench_name "c10_${bench_file_name}")
|
set(bench_name "c10_${bench_file_name}")
|
||||||
add_executable(${bench_name} "${bench_src}")
|
add_executable(${bench_name} "${bench_src}")
|
||||||
target_link_libraries(${bench_name} c10 benchmark)
|
target_link_libraries(${bench_name} c10 benchmark)
|
||||||
if (INSTALL_TEST)
|
if(INSTALL_TEST)
|
||||||
install(TARGETS ${bench_name} DESTINATION test)
|
install(TARGETS ${bench_name} DESTINATION test)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -40,7 +40,7 @@ set(CUDA_LINK_LIBRARIES_KEYWORD)
|
|||||||
# If building shared library, set dllimport/dllexport proper.
|
# If building shared library, set dllimport/dllexport proper.
|
||||||
target_compile_options(c10_cuda PRIVATE "-DC10_CUDA_BUILD_MAIN_LIB")
|
target_compile_options(c10_cuda PRIVATE "-DC10_CUDA_BUILD_MAIN_LIB")
|
||||||
# Enable hidden visibility if compiler supports it.
|
# Enable hidden visibility if compiler supports it.
|
||||||
if (${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
|
if(${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
|
||||||
target_compile_options(c10_cuda PRIVATE "-fvisibility=hidden")
|
target_compile_options(c10_cuda PRIVATE "-fvisibility=hidden")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -69,6 +69,6 @@ endforeach()
|
|||||||
install(FILES ${CMAKE_BINARY_DIR}/c10/cuda/impl/cuda_cmake_macros.h
|
install(FILES ${CMAKE_BINARY_DIR}/c10/cuda/impl/cuda_cmake_macros.h
|
||||||
DESTINATION include/c10/cuda/impl)
|
DESTINATION include/c10/cuda/impl)
|
||||||
|
|
||||||
if (MSVC AND C10_CUDA_BUILD_SHARED_LIBS)
|
if(MSVC AND C10_CUDA_BUILD_SHARED_LIBS)
|
||||||
install(FILES $<TARGET_PDB_FILE:c10_cuda> DESTINATION lib OPTIONAL)
|
install(FILES $<TARGET_PDB_FILE:c10_cuda> DESTINATION lib OPTIONAL)
|
||||||
endif()
|
endif()
|
||||||
|
@ -3,14 +3,14 @@
|
|||||||
set(C10_CUDA_ALL_TEST_FILES
|
set(C10_CUDA_ALL_TEST_FILES
|
||||||
impl/CUDATest.cpp
|
impl/CUDATest.cpp
|
||||||
)
|
)
|
||||||
if (BUILD_TEST)
|
if(BUILD_TEST)
|
||||||
foreach(test_src ${C10_CUDA_ALL_TEST_FILES})
|
foreach(test_src ${C10_CUDA_ALL_TEST_FILES})
|
||||||
get_filename_component(test_file_name ${test_src} NAME_WE)
|
get_filename_component(test_file_name ${test_src} NAME_WE)
|
||||||
set(test_name "c10_cuda_${test_file_name}")
|
set(test_name "c10_cuda_${test_file_name}")
|
||||||
add_executable(${test_name} "${test_src}")
|
add_executable(${test_name} "${test_src}")
|
||||||
target_link_libraries(${test_name} c10_cuda gtest_main)
|
target_link_libraries(${test_name} c10_cuda gtest_main)
|
||||||
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
|
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
|
||||||
if (INSTALL_TEST)
|
if(INSTALL_TEST)
|
||||||
install(TARGETS ${test_name} DESTINATION test)
|
install(TARGETS ${test_name} DESTINATION test)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -37,7 +37,7 @@ target_compile_options(c10_hip PRIVATE ${HIP_CXX_FLAGS})
|
|||||||
# If building shared library, set dllimport/dllexport proper.
|
# If building shared library, set dllimport/dllexport proper.
|
||||||
target_compile_options(c10_hip PRIVATE "-DC10_HIP_BUILD_MAIN_LIB")
|
target_compile_options(c10_hip PRIVATE "-DC10_HIP_BUILD_MAIN_LIB")
|
||||||
# Enable hidden visibility if compiler supports it.
|
# Enable hidden visibility if compiler supports it.
|
||||||
if (${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
|
if(${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
|
||||||
target_compile_options(c10_hip PRIVATE "-fvisibility=hidden")
|
target_compile_options(c10_hip PRIVATE "-fvisibility=hidden")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
# ---[ Test binaries.
|
# ---[ Test binaries.
|
||||||
|
|
||||||
file(GLOB_RECURSE C10_ALL_TEST_FILES *.cpp)
|
file(GLOB_RECURSE C10_ALL_TEST_FILES *.cpp)
|
||||||
if (BUILD_TEST)
|
if(BUILD_TEST)
|
||||||
foreach(test_src ${C10_ALL_TEST_FILES})
|
foreach(test_src ${C10_ALL_TEST_FILES})
|
||||||
get_filename_component(test_file_name ${test_src} NAME_WE)
|
get_filename_component(test_file_name ${test_src} NAME_WE)
|
||||||
set(test_name "c10_${test_file_name}")
|
set(test_name "c10_${test_file_name}")
|
||||||
add_executable(${test_name} "${test_src}")
|
add_executable(${test_name} "${test_src}")
|
||||||
target_link_libraries(${test_name} c10 gmock gtest gtest_main)
|
target_link_libraries(${test_name} c10 gmock gtest gtest_main)
|
||||||
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
|
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
|
||||||
if (INSTALL_TEST)
|
if(INSTALL_TEST)
|
||||||
install(TARGETS ${test_name} DESTINATION test)
|
install(TARGETS ${test_name} DESTINATION test)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -3,7 +3,7 @@ add_subdirectory(nccl)
|
|||||||
add_subdirectory(opencl)
|
add_subdirectory(opencl)
|
||||||
add_subdirectory(prof)
|
add_subdirectory(prof)
|
||||||
add_subdirectory(shm_mutex)
|
add_subdirectory(shm_mutex)
|
||||||
if (USE_TENSORRT)
|
if(USE_TENSORRT)
|
||||||
add_subdirectory(tensorrt)
|
add_subdirectory(tensorrt)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
if(USE_NCCL)
|
if(USE_NCCL)
|
||||||
if (USE_CUDA)
|
if(USE_CUDA)
|
||||||
message(STATUS "Include NCCL operators")
|
message(STATUS "Include NCCL operators")
|
||||||
set(Caffe2_CONTRIB_NCCL_GPU_SRC
|
set(Caffe2_CONTRIB_NCCL_GPU_SRC
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/cuda_nccl_gpu.cc"
|
"${CMAKE_CURRENT_SOURCE_DIR}/cuda_nccl_gpu.cc"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
if (USE_PROF)
|
if(USE_PROF)
|
||||||
set(Caffe2_CONTRIB_PROF_CPU_SRCS
|
set(Caffe2_CONTRIB_PROF_CPU_SRCS
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/prof_dag_stats_op.cc"
|
"${CMAKE_CURRENT_SOURCE_DIR}/prof_dag_stats_op.cc"
|
||||||
)
|
)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
if (INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
|
if(INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
|
||||||
list(APPEND Caffe2_CPU_SRCS
|
list(APPEND Caffe2_CPU_SRCS
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/common.cc"
|
"${CMAKE_CURRENT_SOURCE_DIR}/common.cc"
|
||||||
)
|
)
|
||||||
@ -8,7 +8,7 @@ endif()
|
|||||||
|
|
||||||
# ---[ GPU files
|
# ---[ GPU files
|
||||||
# ------[ cuDNN
|
# ------[ cuDNN
|
||||||
if (USE_CUDNN)
|
if(USE_CUDNN)
|
||||||
file(GLOB tmp *_cudnn.cc)
|
file(GLOB tmp *_cudnn.cc)
|
||||||
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
|
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
|
||||||
endif()
|
endif()
|
||||||
|
@ -15,15 +15,15 @@ list(APPEND Caffe2_GPU_SRCS ${Caffe2_DB_COMMON_GPU_SRC})
|
|||||||
list(APPEND Caffe2_HIP_SRCS ${Caffe2_DB_COMMON_HIP_SRC})
|
list(APPEND Caffe2_HIP_SRCS ${Caffe2_DB_COMMON_HIP_SRC})
|
||||||
|
|
||||||
# DB specific files
|
# DB specific files
|
||||||
if (USE_LMDB)
|
if(USE_LMDB)
|
||||||
list(APPEND Caffe2_CPU_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/lmdb.cc")
|
list(APPEND Caffe2_CPU_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/lmdb.cc")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USE_LEVELDB)
|
if(USE_LEVELDB)
|
||||||
list(APPEND Caffe2_CPU_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/leveldb.cc")
|
list(APPEND Caffe2_CPU_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/leveldb.cc")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USE_ZMQ)
|
if(USE_ZMQ)
|
||||||
list(APPEND Caffe2_CPU_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/zmqdb.cc")
|
list(APPEND Caffe2_CPU_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/zmqdb.cc")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ set(Caffe2_STORE_REDIS_GPU_SRC
|
|||||||
list(APPEND Caffe2_CPU_SRCS ${Caffe2_STORE_COMMON_SRC})
|
list(APPEND Caffe2_CPU_SRCS ${Caffe2_STORE_COMMON_SRC})
|
||||||
list(APPEND Caffe2_GPU_SRCS ${Caffe2_STORE_COMMON_GPU_SRC})
|
list(APPEND Caffe2_GPU_SRCS ${Caffe2_STORE_COMMON_GPU_SRC})
|
||||||
|
|
||||||
if (USE_REDIS)
|
if(USE_REDIS)
|
||||||
list(APPEND Caffe2_CPU_SRCS ${Caffe2_STORE_REDIS_SRC})
|
list(APPEND Caffe2_CPU_SRCS ${Caffe2_STORE_REDIS_SRC})
|
||||||
list(APPEND Caffe2_GPU_SRCS ${Caffe2_STORE_REDIS_GPU_SRC})
|
list(APPEND Caffe2_GPU_SRCS ${Caffe2_STORE_REDIS_GPU_SRC})
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
add_subdirectory(ios)
|
add_subdirectory(ios)
|
||||||
|
|
||||||
if (USE_NNAPI)
|
if(USE_NNAPI)
|
||||||
add_subdirectory(nnapi)
|
add_subdirectory(nnapi)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ if(IOS)
|
|||||||
)
|
)
|
||||||
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${Caffe2_CONTRIB_IOS_SRC})
|
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${Caffe2_CONTRIB_IOS_SRC})
|
||||||
|
|
||||||
if (USE_METAL)
|
if(USE_METAL)
|
||||||
# metal/mpscnn files
|
# metal/mpscnn files
|
||||||
add_subdirectory(mpscnn)
|
add_subdirectory(mpscnn)
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
if (USE_NNAPI AND ANDROID)
|
if(USE_NNAPI AND ANDROID)
|
||||||
set(Caffe2_CONTRIB_NNAPI_CPU_SRC
|
set(Caffe2_CONTRIB_NNAPI_CPU_SRC
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/dlnnapi.c"
|
"${CMAKE_CURRENT_SOURCE_DIR}/dlnnapi.c"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/nnapi.cc"
|
"${CMAKE_CURRENT_SOURCE_DIR}/nnapi.cc"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# ---[ GPU files
|
# ---[ GPU files
|
||||||
# ------[ cuDNN
|
# ------[ cuDNN
|
||||||
if (USE_CUDNN)
|
if(USE_CUDNN)
|
||||||
file(GLOB tmp *_cudnn.cc *_cudnn.cu)
|
file(GLOB tmp *_cudnn.cc *_cudnn.cu)
|
||||||
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
|
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
|
||||||
endif()
|
endif()
|
||||||
@ -8,7 +8,7 @@ endif()
|
|||||||
file(GLOB tmp *_gpu.cc)
|
file(GLOB tmp *_gpu.cc)
|
||||||
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
|
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
|
||||||
# ------[ TensorRT
|
# ------[ TensorRT
|
||||||
if (USE_TENSORRT)
|
if(USE_TENSORRT)
|
||||||
file(GLOB tmp *_trt.cc)
|
file(GLOB tmp *_trt.cc)
|
||||||
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
|
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
|
||||||
endif()
|
endif()
|
||||||
@ -42,7 +42,7 @@ exclude(tmp "${tmp}" ${tmp_cudnn})
|
|||||||
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${tmp})
|
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${tmp})
|
||||||
|
|
||||||
# Add all files in experimental
|
# Add all files in experimental
|
||||||
if (NOT INTERN_BUILD_MOBILE)
|
if(NOT INTERN_BUILD_MOBILE)
|
||||||
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${CMAKE_CURRENT_LIST_DIR}/experimental/c10/cpu/flatten_cpu.cc)
|
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${CMAKE_CURRENT_LIST_DIR}/experimental/c10/cpu/flatten_cpu.cc)
|
||||||
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${CMAKE_CURRENT_LIST_DIR}/experimental/c10/cpu/averaged_loss_cpu.cc)
|
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${CMAKE_CURRENT_LIST_DIR}/experimental/c10/cpu/averaged_loss_cpu.cc)
|
||||||
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${CMAKE_CURRENT_LIST_DIR}/experimental/c10/cpu/mul_cpu.cc)
|
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${CMAKE_CURRENT_LIST_DIR}/experimental/c10/cpu/mul_cpu.cc)
|
||||||
@ -70,7 +70,7 @@ exclude(Caffe2_CPU_SRCS "${Caffe2_CPU_SRCS}" ${Caffe2_GPU_SRCS} ${Caffe2_HIP_SRC
|
|||||||
|
|
||||||
# ---[ GPU test files
|
# ---[ GPU test files
|
||||||
# ------[ cuDNN
|
# ------[ cuDNN
|
||||||
if (USE_CUDNN)
|
if(USE_CUDNN)
|
||||||
file(GLOB tmp *_cudnn_test.cc)
|
file(GLOB tmp *_cudnn_test.cc)
|
||||||
set(Caffe2_GPU_TEST_SRCS ${Caffe2_GPU_TEST_SRCS} ${tmp})
|
set(Caffe2_GPU_TEST_SRCS ${Caffe2_GPU_TEST_SRCS} ${tmp})
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# ---[ GPU files
|
# ---[ GPU files
|
||||||
# ------[ cuDNN
|
# ------[ cuDNN
|
||||||
if (USE_CUDNN)
|
if(USE_CUDNN)
|
||||||
file(GLOB tmp *_cudnn.cc)
|
file(GLOB tmp *_cudnn.cc)
|
||||||
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
|
set(Caffe2_GPU_SRCS ${Caffe2_GPU_SRCS} ${tmp})
|
||||||
endif()
|
endif()
|
||||||
@ -38,7 +38,7 @@ exclude(Caffe2_CPU_SRCS "${Caffe2_CPU_SRCS}" ${Caffe2_GPU_SRCS} ${Caffe2_HIP_SRC
|
|||||||
|
|
||||||
# ---[ GPU test files
|
# ---[ GPU test files
|
||||||
# ------[ cuDNN
|
# ------[ cuDNN
|
||||||
if (USE_CUDNN)
|
if(USE_CUDNN)
|
||||||
file(GLOB tmp *_cudnn_test.cc)
|
file(GLOB tmp *_cudnn_test.cc)
|
||||||
set(Caffe2_GPU_TEST_SRCS ${Caffe2_GPU_TEST_SRCS} ${tmp})
|
set(Caffe2_GPU_TEST_SRCS ${Caffe2_GPU_TEST_SRCS} ${tmp})
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
if (INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
|
if(INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
|
||||||
list(APPEND Caffe2_CPU_SRCS
|
list(APPEND Caffe2_CPU_SRCS
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/embedding_lookup_idx.cc"
|
"${CMAKE_CURRENT_SOURCE_DIR}/embedding_lookup_idx.cc"
|
||||||
)
|
)
|
||||||
@ -21,14 +21,14 @@ set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${common_srcs})
|
|||||||
|
|
||||||
# We will only build the perf kernel files if the compiler supports avx2
|
# We will only build the perf kernel files if the compiler supports avx2
|
||||||
# extensions.
|
# extensions.
|
||||||
if (CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS)
|
if(CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS)
|
||||||
add_library(Caffe2_perfkernels_avx STATIC ${avx_srcs})
|
add_library(Caffe2_perfkernels_avx STATIC ${avx_srcs})
|
||||||
add_library(Caffe2_perfkernels_avx2 STATIC ${avx2_srcs})
|
add_library(Caffe2_perfkernels_avx2 STATIC ${avx2_srcs})
|
||||||
add_dependencies(Caffe2_perfkernels_avx Caffe2_PROTO)
|
add_dependencies(Caffe2_perfkernels_avx Caffe2_PROTO)
|
||||||
add_dependencies(Caffe2_perfkernels_avx2 Caffe2_PROTO)
|
add_dependencies(Caffe2_perfkernels_avx2 Caffe2_PROTO)
|
||||||
target_link_libraries(Caffe2_perfkernels_avx PRIVATE c10)
|
target_link_libraries(Caffe2_perfkernels_avx PRIVATE c10)
|
||||||
target_link_libraries(Caffe2_perfkernels_avx2 PRIVATE c10)
|
target_link_libraries(Caffe2_perfkernels_avx2 PRIVATE c10)
|
||||||
if (MSVC)
|
if(MSVC)
|
||||||
target_compile_options(Caffe2_perfkernels_avx
|
target_compile_options(Caffe2_perfkernels_avx
|
||||||
PRIVATE "/arch:AVX"
|
PRIVATE "/arch:AVX"
|
||||||
PRIVATE "/D__F16C__")
|
PRIVATE "/D__F16C__")
|
||||||
@ -57,11 +57,11 @@ if (CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS)
|
|||||||
Caffe2_DEPENDENCY_WHOLE_LINK_LIBS
|
Caffe2_DEPENDENCY_WHOLE_LINK_LIBS
|
||||||
"Caffe2_perfkernels_avx2_interface")
|
"Caffe2_perfkernels_avx2_interface")
|
||||||
|
|
||||||
if (CAFFE2_COMPILER_SUPPORTS_AVX512_EXTENSIONS)
|
if(CAFFE2_COMPILER_SUPPORTS_AVX512_EXTENSIONS)
|
||||||
add_library(Caffe2_perfkernels_avx512 STATIC ${avx512_srcs})
|
add_library(Caffe2_perfkernels_avx512 STATIC ${avx512_srcs})
|
||||||
add_dependencies(Caffe2_perfkernels_avx512 Caffe2_PROTO)
|
add_dependencies(Caffe2_perfkernels_avx512 Caffe2_PROTO)
|
||||||
target_link_libraries(Caffe2_perfkernels_avx512 PRIVATE c10)
|
target_link_libraries(Caffe2_perfkernels_avx512 PRIVATE c10)
|
||||||
if (MSVC)
|
if(MSVC)
|
||||||
target_compile_options(Caffe2_perfkernels_avx512
|
target_compile_options(Caffe2_perfkernels_avx512
|
||||||
PRIVATE "/D__AVX512F__"
|
PRIVATE "/D__AVX512F__"
|
||||||
PRIVATE "/D__AVX512DQ__"
|
PRIVATE "/D__AVX512DQ__"
|
||||||
|
@ -4,7 +4,7 @@ caffe2_protobuf_generate_cpp_py(Caffe2_PROTO_SRCS Caffe2_PROTO_HEADERS Caffe2_PR
|
|||||||
|
|
||||||
add_library(Caffe2_PROTO OBJECT ${Caffe2_PROTO_HEADERS} ${Caffe2_PROTO_SRCS})
|
add_library(Caffe2_PROTO OBJECT ${Caffe2_PROTO_HEADERS} ${Caffe2_PROTO_SRCS})
|
||||||
|
|
||||||
if (MSVC)
|
if(MSVC)
|
||||||
if(BUILD_SHARED_LIBS)
|
if(BUILD_SHARED_LIBS)
|
||||||
set(Caffe2_API_DEFINE "-DCAFFE2_API=__declspec(dllexport)")
|
set(Caffe2_API_DEFINE "-DCAFFE2_API=__declspec(dllexport)")
|
||||||
else()
|
else()
|
||||||
|
@ -60,13 +60,13 @@ list(APPEND Caffe2_CPU_SRCS
|
|||||||
#"${CMAKE_CURRENT_SOURCE_DIR}/sigmoid_test.cc")
|
#"${CMAKE_CURRENT_SOURCE_DIR}/sigmoid_test.cc")
|
||||||
#"${CMAKE_CURRENT_SOURCE_DIR}/tanh_test.cc")
|
#"${CMAKE_CURRENT_SOURCE_DIR}/tanh_test.cc")
|
||||||
|
|
||||||
if (CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS)
|
if(CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS)
|
||||||
add_library(caffe2_dnnlowp_avx2_ops OBJECT ${caffe2_dnnlowp_avx2_ops_SRCS})
|
add_library(caffe2_dnnlowp_avx2_ops OBJECT ${caffe2_dnnlowp_avx2_ops_SRCS})
|
||||||
add_dependencies(caffe2_dnnlowp_avx2_ops fbgemm Caffe2_PROTO c10)
|
add_dependencies(caffe2_dnnlowp_avx2_ops fbgemm Caffe2_PROTO c10)
|
||||||
target_include_directories(caffe2_dnnlowp_avx2_ops BEFORE
|
target_include_directories(caffe2_dnnlowp_avx2_ops BEFORE
|
||||||
PRIVATE $<BUILD_INTERFACE:${FBGEMM_SOURCE_DIR}/include>)
|
PRIVATE $<BUILD_INTERFACE:${FBGEMM_SOURCE_DIR}/include>)
|
||||||
|
|
||||||
if (MSVC)
|
if(MSVC)
|
||||||
set_property(SOURCE ${caffe2_dnnlowp_avx2_ops_SRCS}
|
set_property(SOURCE ${caffe2_dnnlowp_avx2_ops_SRCS}
|
||||||
APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX2 ")
|
APPEND_STRING PROPERTY COMPILE_FLAGS " /arch:AVX2 ")
|
||||||
else()
|
else()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# There is a linking issue that happens in some of the Windows builds.
|
# There is a linking issue that happens in some of the Windows builds.
|
||||||
# TODO(Yangqing): after the module redesing, enable this back.
|
# TODO(Yangqing): after the module redesing, enable this back.
|
||||||
if (NOT MSVC)
|
if(NOT MSVC)
|
||||||
add_subdirectory(contrib)
|
add_subdirectory(contrib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
if (USE_NNPACK AND BUILD_CAFFE2_OPS)
|
if(USE_NNPACK AND BUILD_CAFFE2_OPS)
|
||||||
add_subdirectory(nnpack)
|
add_subdirectory(nnpack)
|
||||||
endif()
|
endif()
|
||||||
if (USE_ZSTD)
|
if(USE_ZSTD)
|
||||||
add_subdirectory(zstd)
|
add_subdirectory(zstd)
|
||||||
endif()
|
endif()
|
||||||
if (NOT MSVC)
|
if(NOT MSVC)
|
||||||
add_subdirectory(depthwise)
|
add_subdirectory(depthwise)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# TODO: Add ThreadPoolXNNPACK.cc when XNNPACK integration is updated
|
# TODO: Add ThreadPoolXNNPACK.cc when XNNPACK integration is updated
|
||||||
# to pass the actual threadpool ptr instead of nullptr.
|
# to pass the actual threadpool ptr instead of nullptr.
|
||||||
if (INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
|
if(INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
|
||||||
add_definitions(-DUSE_INTERNAL_THREADPOOL_IMPL)
|
add_definitions(-DUSE_INTERNAL_THREADPOOL_IMPL)
|
||||||
list(APPEND Caffe2_CPU_SRCS
|
list(APPEND Caffe2_CPU_SRCS
|
||||||
utils/string_utils.cc
|
utils/string_utils.cc
|
||||||
@ -36,7 +36,7 @@ list(APPEND Caffe2_CPU_SRCS
|
|||||||
# ---[ threadpool/pthreadpool* is a local modification of the NNPACK
|
# ---[ threadpool/pthreadpool* is a local modification of the NNPACK
|
||||||
# pthreadpool with a very similar interface. Neither NNPACK, nor this
|
# pthreadpool with a very similar interface. Neither NNPACK, nor this
|
||||||
# thread pool supports Windows.
|
# thread pool supports Windows.
|
||||||
if (NOT MSVC)
|
if(NOT MSVC)
|
||||||
add_definitions(-DUSE_INTERNAL_THREADPOOL_IMPL)
|
add_definitions(-DUSE_INTERNAL_THREADPOOL_IMPL)
|
||||||
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS}
|
set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS}
|
||||||
utils/threadpool/pthreadpool.cc
|
utils/threadpool/pthreadpool.cc
|
||||||
|
@ -18,9 +18,9 @@ include("${CMAKE_CURRENT_LIST_DIR}/public/threads.cmake")
|
|||||||
|
|
||||||
# Depending on whether Caffe2 uses gflags during compile time or
|
# Depending on whether Caffe2 uses gflags during compile time or
|
||||||
# not, invoke gflags.
|
# not, invoke gflags.
|
||||||
if (@USE_GFLAGS@)
|
if(@USE_GFLAGS@)
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/public/gflags.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/public/gflags.cmake")
|
||||||
if (NOT TARGET gflags)
|
if(NOT TARGET gflags)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"Your installed Caffe2 version uses gflags but the gflags library "
|
"Your installed Caffe2 version uses gflags but the gflags library "
|
||||||
"cannot be found. Did you accidentally remove it, or have you set "
|
"cannot be found. Did you accidentally remove it, or have you set "
|
||||||
@ -32,9 +32,9 @@ endif()
|
|||||||
|
|
||||||
# Depending on whether Caffe2 uses glog during compile time or
|
# Depending on whether Caffe2 uses glog during compile time or
|
||||||
# not, invoke glog.
|
# not, invoke glog.
|
||||||
if (@USE_GLOG@)
|
if(@USE_GLOG@)
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/public/glog.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/public/glog.cmake")
|
||||||
if (NOT TARGET glog::glog)
|
if(NOT TARGET glog::glog)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"Your installed Caffe2 version uses glog but the glog library "
|
"Your installed Caffe2 version uses glog but the glog library "
|
||||||
"cannot be found. Did you accidentally remove it, or have you set "
|
"cannot be found. Did you accidentally remove it, or have you set "
|
||||||
@ -45,8 +45,8 @@ if (@USE_GLOG@)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Protobuf
|
# Protobuf
|
||||||
if (@CAFFE2_LINK_LOCAL_PROTOBUF@)
|
if(@CAFFE2_LINK_LOCAL_PROTOBUF@)
|
||||||
if (NOT TARGET protobuf::libprotobuf)
|
if(NOT TARGET protobuf::libprotobuf)
|
||||||
# Define protobuf::libprotobuf as a dummy target to resolve references to
|
# Define protobuf::libprotobuf as a dummy target to resolve references to
|
||||||
# protobuf::libprotobuf in Caffe2Targets.cmake.
|
# protobuf::libprotobuf in Caffe2Targets.cmake.
|
||||||
add_library(dummy INTERFACE)
|
add_library(dummy INTERFACE)
|
||||||
@ -54,7 +54,7 @@ if (@CAFFE2_LINK_LOCAL_PROTOBUF@)
|
|||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/public/protobuf.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/public/protobuf.cmake")
|
||||||
if (NOT TARGET protobuf::libprotobuf)
|
if(NOT TARGET protobuf::libprotobuf)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"Your installed Caffe2 version uses protobuf but the protobuf library "
|
"Your installed Caffe2 version uses protobuf but the protobuf library "
|
||||||
"cannot be found. Did you accidentally remove it, or have you set "
|
"cannot be found. Did you accidentally remove it, or have you set "
|
||||||
@ -65,8 +65,8 @@ else()
|
|||||||
# If during build time we know the protobuf version, we will also do a sanity
|
# If during build time we know the protobuf version, we will also do a sanity
|
||||||
# check to ensure that the protobuf library that Caffe2 found is consistent
|
# check to ensure that the protobuf library that Caffe2 found is consistent
|
||||||
# with the compiled version.
|
# with the compiled version.
|
||||||
if (@CAFFE2_KNOWN_PROTOBUF_VERSION@)
|
if(@CAFFE2_KNOWN_PROTOBUF_VERSION@)
|
||||||
if (NOT (${Protobuf_VERSION} VERSION_EQUAL @Protobuf_VERSION@))
|
if(NOT (${Protobuf_VERSION} VERSION_EQUAL @Protobuf_VERSION@))
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"Your installed Caffe2 is built with protobuf "
|
"Your installed Caffe2 is built with protobuf "
|
||||||
"@Protobuf_VERSION@"
|
"@Protobuf_VERSION@"
|
||||||
@ -78,7 +78,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (@USE_CUDA@)
|
if(@USE_CUDA@)
|
||||||
# The file public/cuda.cmake exclusively uses CAFFE2_USE_*.
|
# The file public/cuda.cmake exclusively uses CAFFE2_USE_*.
|
||||||
# If Caffe2 was compiled with the libraries below, they must
|
# If Caffe2 was compiled with the libraries below, they must
|
||||||
# be found again when including the Caffe2 target.
|
# be found again when including the Caffe2 target.
|
||||||
@ -86,19 +86,19 @@ if (@USE_CUDA@)
|
|||||||
set(CAFFE2_USE_CUDNN @USE_CUDNN@)
|
set(CAFFE2_USE_CUDNN @USE_CUDNN@)
|
||||||
set(CAFFE2_USE_TENSORRT @USE_TENSORRT@)
|
set(CAFFE2_USE_TENSORRT @USE_TENSORRT@)
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/public/cuda.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/public/cuda.cmake")
|
||||||
if (@CAFFE2_USE_CUDA@ AND NOT CAFFE2_USE_CUDA)
|
if(@CAFFE2_USE_CUDA@ AND NOT CAFFE2_USE_CUDA)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"Your installed Caffe2 version uses CUDA but I cannot find the CUDA "
|
"Your installed Caffe2 version uses CUDA but I cannot find the CUDA "
|
||||||
"libraries. Please set the proper CUDA prefixes and / or install "
|
"libraries. Please set the proper CUDA prefixes and / or install "
|
||||||
"CUDA.")
|
"CUDA.")
|
||||||
endif()
|
endif()
|
||||||
if (@CAFFE2_USE_CUDNN@ AND NOT CAFFE2_USE_CUDNN)
|
if(@CAFFE2_USE_CUDNN@ AND NOT CAFFE2_USE_CUDNN)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"Your installed Caffe2 version uses cuDNN but I cannot find the cuDNN "
|
"Your installed Caffe2 version uses cuDNN but I cannot find the cuDNN "
|
||||||
"libraries. Please set the proper cuDNN prefixes and / or install "
|
"libraries. Please set the proper cuDNN prefixes and / or install "
|
||||||
"cuDNN.")
|
"cuDNN.")
|
||||||
endif()
|
endif()
|
||||||
if (@CAFFE2_USE_TENSORRT@ AND NOT CAFFE2_USE_TENSORRT)
|
if(@CAFFE2_USE_TENSORRT@ AND NOT CAFFE2_USE_TENSORRT)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"Your installed Caffe2 version uses TensorRT but I cannot find the TensorRT "
|
"Your installed Caffe2 version uses TensorRT but I cannot find the TensorRT "
|
||||||
"libraries. Please set the proper TensorRT prefixes and / or install "
|
"libraries. Please set the proper TensorRT prefixes and / or install "
|
||||||
@ -108,7 +108,7 @@ endif()
|
|||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/public/mkl.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/public/mkl.cmake")
|
||||||
|
|
||||||
if (@USE_MKLDNN@)
|
if(@USE_MKLDNN@)
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/public/mkldnn.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/public/mkldnn.cmake")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
|
|||||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||||
else()
|
else()
|
||||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||||
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
|
if("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
|
||||||
set(PACKAGE_VERSION_EXACT TRUE)
|
set(PACKAGE_VERSION_EXACT TRUE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -43,7 +43,7 @@ configure_file(
|
|||||||
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../caffe2
|
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../caffe2
|
||||||
DESTINATION include
|
DESTINATION include
|
||||||
FILES_MATCHING PATTERN "*.h")
|
FILES_MATCHING PATTERN "*.h")
|
||||||
if (NOT INTERN_BUILD_ATEN_OPS)
|
if(NOT INTERN_BUILD_ATEN_OPS)
|
||||||
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../aten/src/ATen/core
|
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../aten/src/ATen/core
|
||||||
DESTINATION include/ATen
|
DESTINATION include/ATen
|
||||||
FILES_MATCHING PATTERN "*.h")
|
FILES_MATCHING PATTERN "*.h")
|
||||||
@ -52,44 +52,44 @@ install(FILES ${CMAKE_BINARY_DIR}/caffe2/core/macros.h
|
|||||||
DESTINATION include/caffe2/core)
|
DESTINATION include/caffe2/core)
|
||||||
|
|
||||||
# ---[ ATen specific
|
# ---[ ATen specific
|
||||||
if (INTERN_BUILD_ATEN_OPS)
|
if(INTERN_BUILD_ATEN_OPS)
|
||||||
IF(MSVC)
|
if(MSVC)
|
||||||
SET(OPT_FLAG "/fp:strict ")
|
SET(OPT_FLAG "/fp:strict ")
|
||||||
ELSE(MSVC)
|
else(MSVC)
|
||||||
SET(OPT_FLAG "-O3 ")
|
SET(OPT_FLAG "-O3 ")
|
||||||
IF("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
|
if("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
|
||||||
SET(OPT_FLAG " ")
|
SET(OPT_FLAG " ")
|
||||||
ENDIF()
|
endif()
|
||||||
ENDIF(MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
IF(C_AVX_FOUND)
|
if(C_AVX_FOUND)
|
||||||
IF(MSVC)
|
if(MSVC)
|
||||||
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_LIST_DIR}/../aten/src/TH/vector/AVX.cpp PROPERTIES COMPILE_FLAGS "${OPT_FLAG}/arch:AVX ${CXX_AVX_FLAGS}")
|
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_LIST_DIR}/../aten/src/TH/vector/AVX.cpp PROPERTIES COMPILE_FLAGS "${OPT_FLAG}/arch:AVX ${CXX_AVX_FLAGS}")
|
||||||
ELSE(MSVC)
|
else(MSVC)
|
||||||
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_LIST_DIR}/../aten/src/TH/vector/AVX.cpp PROPERTIES COMPILE_FLAGS "${OPT_FLAG} ${CXX_AVX_FLAGS}")
|
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_LIST_DIR}/../aten/src/TH/vector/AVX.cpp PROPERTIES COMPILE_FLAGS "${OPT_FLAG} ${CXX_AVX_FLAGS}")
|
||||||
ENDIF(MSVC)
|
endif(MSVC)
|
||||||
ENDIF(C_AVX_FOUND)
|
endif(C_AVX_FOUND)
|
||||||
|
|
||||||
IF(NOT MSVC AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
|
if(NOT MSVC AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
|
||||||
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_LIST_DIR}/../aten/src/TH/THAllocator.cpp PROPERTIES COMPILE_FLAGS "-fno-openmp")
|
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_LIST_DIR}/../aten/src/TH/THAllocator.cpp PROPERTIES COMPILE_FLAGS "-fno-openmp")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
FILE(GLOB cpu_kernel_cpp_in "${CMAKE_CURRENT_LIST_DIR}/../aten/src/ATen/native/cpu/*.cpp" "${CMAKE_CURRENT_LIST_DIR}/../aten/src/ATen/native/quantized/cpu/kernels/*.cpp")
|
FILE(GLOB cpu_kernel_cpp_in "${CMAKE_CURRENT_LIST_DIR}/../aten/src/ATen/native/cpu/*.cpp" "${CMAKE_CURRENT_LIST_DIR}/../aten/src/ATen/native/quantized/cpu/kernels/*.cpp")
|
||||||
|
|
||||||
LIST(APPEND CPU_CAPABILITY_NAMES "DEFAULT")
|
LIST(APPEND CPU_CAPABILITY_NAMES "DEFAULT")
|
||||||
LIST(APPEND CPU_CAPABILITY_FLAGS "${OPT_FLAG}")
|
LIST(APPEND CPU_CAPABILITY_FLAGS "${OPT_FLAG}")
|
||||||
|
|
||||||
IF(CXX_AVX_FOUND)
|
if(CXX_AVX_FOUND)
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_AVX_CPU_DEFINITION")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_AVX_CPU_DEFINITION")
|
||||||
LIST(APPEND CPU_CAPABILITY_NAMES "AVX")
|
LIST(APPEND CPU_CAPABILITY_NAMES "AVX")
|
||||||
IF(MSVC)
|
if(MSVC)
|
||||||
LIST(APPEND CPU_CAPABILITY_FLAGS "${OPT_FLAG}/arch:AVX")
|
LIST(APPEND CPU_CAPABILITY_FLAGS "${OPT_FLAG}/arch:AVX")
|
||||||
ELSE(MSVC)
|
else(MSVC)
|
||||||
LIST(APPEND CPU_CAPABILITY_FLAGS "${OPT_FLAG} -mavx")
|
LIST(APPEND CPU_CAPABILITY_FLAGS "${OPT_FLAG} -mavx")
|
||||||
ENDIF(MSVC)
|
endif(MSVC)
|
||||||
ENDIF(CXX_AVX_FOUND)
|
endif(CXX_AVX_FOUND)
|
||||||
|
|
||||||
IF(CXX_AVX2_FOUND)
|
if(CXX_AVX2_FOUND)
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_AVX2_CPU_DEFINITION")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_AVX2_CPU_DEFINITION")
|
||||||
|
|
||||||
# Some versions of GCC pessimistically split unaligned load and store
|
# Some versions of GCC pessimistically split unaligned load and store
|
||||||
@ -97,17 +97,17 @@ if (INTERN_BUILD_ATEN_OPS)
|
|||||||
# new Intel and AMD processors so we disable it when compiling with AVX2.
|
# new Intel and AMD processors so we disable it when compiling with AVX2.
|
||||||
# See https://stackoverflow.com/questions/52626726/why-doesnt-gcc-resolve-mm256-loadu-pd-as-single-vmovupd#tab-top
|
# See https://stackoverflow.com/questions/52626726/why-doesnt-gcc-resolve-mm256-loadu-pd-as-single-vmovupd#tab-top
|
||||||
check_cxx_compiler_flag("-mno-avx256-split-unaligned-load -mno-avx256-split-unaligned-store" COMPILER_SUPPORTS_NO_AVX256_SPLIT)
|
check_cxx_compiler_flag("-mno-avx256-split-unaligned-load -mno-avx256-split-unaligned-store" COMPILER_SUPPORTS_NO_AVX256_SPLIT)
|
||||||
IF(COMPILER_SUPPORTS_NO_AVX256_SPLIT)
|
if(COMPILER_SUPPORTS_NO_AVX256_SPLIT)
|
||||||
SET(CPU_NO_AVX256_SPLIT_FLAGS "-mno-avx256-split-unaligned-load -mno-avx256-split-unaligned-store")
|
SET(CPU_NO_AVX256_SPLIT_FLAGS "-mno-avx256-split-unaligned-load -mno-avx256-split-unaligned-store")
|
||||||
ENDIF(COMPILER_SUPPORTS_NO_AVX256_SPLIT)
|
endif(COMPILER_SUPPORTS_NO_AVX256_SPLIT)
|
||||||
|
|
||||||
LIST(APPEND CPU_CAPABILITY_NAMES "AVX2")
|
LIST(APPEND CPU_CAPABILITY_NAMES "AVX2")
|
||||||
IF(MSVC)
|
if(MSVC)
|
||||||
LIST(APPEND CPU_CAPABILITY_FLAGS "${OPT_FLAG}/arch:AVX2")
|
LIST(APPEND CPU_CAPABILITY_FLAGS "${OPT_FLAG}/arch:AVX2")
|
||||||
ELSE(MSVC)
|
else(MSVC)
|
||||||
LIST(APPEND CPU_CAPABILITY_FLAGS "${OPT_FLAG} -mavx2 -mfma ${CPU_NO_AVX256_SPLIT_FLAGS}")
|
LIST(APPEND CPU_CAPABILITY_FLAGS "${OPT_FLAG} -mavx2 -mfma ${CPU_NO_AVX256_SPLIT_FLAGS}")
|
||||||
ENDIF(MSVC)
|
endif(MSVC)
|
||||||
ENDIF(CXX_AVX2_FOUND)
|
endif(CXX_AVX2_FOUND)
|
||||||
|
|
||||||
list(LENGTH CPU_CAPABILITY_NAMES NUM_CPU_CAPABILITY_NAMES)
|
list(LENGTH CPU_CAPABILITY_NAMES NUM_CPU_CAPABILITY_NAMES)
|
||||||
math(EXPR NUM_CPU_CAPABILITY_NAMES "${NUM_CPU_CAPABILITY_NAMES}-1")
|
math(EXPR NUM_CPU_CAPABILITY_NAMES "${NUM_CPU_CAPABILITY_NAMES}-1")
|
||||||
@ -120,11 +120,11 @@ if (INTERN_BUILD_ATEN_OPS)
|
|||||||
CONFIGURE_FILE(${IMPL} ${NEW_IMPL} COPYONLY)
|
CONFIGURE_FILE(${IMPL} ${NEW_IMPL} COPYONLY)
|
||||||
SET(cpu_kernel_cpp ${NEW_IMPL} ${cpu_kernel_cpp}) # Create list of copies
|
SET(cpu_kernel_cpp ${NEW_IMPL} ${cpu_kernel_cpp}) # Create list of copies
|
||||||
LIST(GET CPU_CAPABILITY_FLAGS ${i} FLAGS)
|
LIST(GET CPU_CAPABILITY_FLAGS ${i} FLAGS)
|
||||||
IF(MSVC)
|
if(MSVC)
|
||||||
SET(MACRO_FLAG "/DCPU_CAPABILITY=${CPU_CAPABILITY} /DCPU_CAPABILITY_${CPU_CAPABILITY}")
|
SET(MACRO_FLAG "/DCPU_CAPABILITY=${CPU_CAPABILITY} /DCPU_CAPABILITY_${CPU_CAPABILITY}")
|
||||||
ELSE(MSVC)
|
else(MSVC)
|
||||||
SET(MACRO_FLAG "-DCPU_CAPABILITY=${CPU_CAPABILITY} -DCPU_CAPABILITY_${CPU_CAPABILITY}")
|
SET(MACRO_FLAG "-DCPU_CAPABILITY=${CPU_CAPABILITY} -DCPU_CAPABILITY_${CPU_CAPABILITY}")
|
||||||
ENDIF(MSVC)
|
endif(MSVC)
|
||||||
SET_SOURCE_FILES_PROPERTIES(${NEW_IMPL} PROPERTIES COMPILE_FLAGS "${FLAGS} ${MACRO_FLAG}")
|
SET_SOURCE_FILES_PROPERTIES(${NEW_IMPL} PROPERTIES COMPILE_FLAGS "${FLAGS} ${MACRO_FLAG}")
|
||||||
ENDFOREACH()
|
ENDFOREACH()
|
||||||
ENDFOREACH()
|
ENDFOREACH()
|
||||||
@ -139,13 +139,13 @@ if (INTERN_BUILD_ATEN_OPS)
|
|||||||
FILE(GLOB all_python "${CMAKE_CURRENT_LIST_DIR}/../aten/src/ATen/*.py")
|
FILE(GLOB all_python "${CMAKE_CURRENT_LIST_DIR}/../aten/src/ATen/*.py")
|
||||||
|
|
||||||
set(GEN_ROCM_FLAG)
|
set(GEN_ROCM_FLAG)
|
||||||
if (USE_ROCM)
|
if(USE_ROCM)
|
||||||
set(GEN_ROCM_FLAG --rocm)
|
set(GEN_ROCM_FLAG --rocm)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CUSTOM_BUILD_FLAGS)
|
set(CUSTOM_BUILD_FLAGS)
|
||||||
if (SELECTED_OP_LIST)
|
if(SELECTED_OP_LIST)
|
||||||
if (NOT USE_STATIC_DISPATCH AND NOT OP_DEPENDENCY)
|
if(NOT USE_STATIC_DISPATCH AND NOT OP_DEPENDENCY)
|
||||||
message(FATAL_ERROR "Must provide op dependency graph .yaml file for custom build with dynamic dispatch!")
|
message(FATAL_ERROR "Must provide op dependency graph .yaml file for custom build with dynamic dispatch!")
|
||||||
endif()
|
endif()
|
||||||
EXECUTE_PROCESS(
|
EXECUTE_PROCESS(
|
||||||
@ -176,7 +176,7 @@ if (INTERN_BUILD_ATEN_OPS)
|
|||||||
--output-dependencies ${CMAKE_BINARY_DIR}/aten/src/ATen/generated_cpp.txt
|
--output-dependencies ${CMAKE_BINARY_DIR}/aten/src/ATen/generated_cpp.txt
|
||||||
RESULT_VARIABLE RETURN_VALUE
|
RESULT_VARIABLE RETURN_VALUE
|
||||||
)
|
)
|
||||||
if (NOT RETURN_VALUE EQUAL 0)
|
if(NOT RETURN_VALUE EQUAL 0)
|
||||||
message(STATUS ${generated_cpp})
|
message(STATUS ${generated_cpp})
|
||||||
message(FATAL_ERROR "Failed to get generated_cpp list")
|
message(FATAL_ERROR "Failed to get generated_cpp list")
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# RPATH stuff
|
# RPATH stuff
|
||||||
# see https://cmake.org/Wiki/CMake_RPATH_handling
|
# see https://cmake.org/Wiki/CMake_RPATH_handling
|
||||||
if (APPLE)
|
if(APPLE)
|
||||||
set(CMAKE_MACOSX_RPATH ON)
|
set(CMAKE_MACOSX_RPATH ON)
|
||||||
set(_rpath_portable_origin "@loader_path")
|
set(_rpath_portable_origin "@loader_path")
|
||||||
else()
|
else()
|
||||||
@ -19,7 +19,7 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|||||||
set(UBSAN_FLAG "-fsanitize=undefined")
|
set(UBSAN_FLAG "-fsanitize=undefined")
|
||||||
|
|
||||||
macro(disable_ubsan)
|
macro(disable_ubsan)
|
||||||
if (CMAKE_C_FLAGS MATCHES ${UBSAN_FLAG} OR CMAKE_CXX_FLAGS MATCHES ${UBSAN_FLAG})
|
if(CMAKE_C_FLAGS MATCHES ${UBSAN_FLAG} OR CMAKE_CXX_FLAGS MATCHES ${UBSAN_FLAG})
|
||||||
set(CAFFE2_UBSAN_ENABLED ON)
|
set(CAFFE2_UBSAN_ENABLED ON)
|
||||||
string(REPLACE ${UBSAN_FLAG} "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
string(REPLACE ${UBSAN_FLAG} "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||||
string(REPLACE ${UBSAN_FLAG} "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
string(REPLACE ${UBSAN_FLAG} "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||||
@ -27,7 +27,7 @@ macro(disable_ubsan)
|
|||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(enable_ubsan)
|
macro(enable_ubsan)
|
||||||
if (CAFFE2_UBSAN_ENABLED)
|
if(CAFFE2_UBSAN_ENABLED)
|
||||||
set(CMAKE_C_FLAGS "${UBSAN_FLAG} ${CMAKE_C_FLAGS}")
|
set(CMAKE_C_FLAGS "${UBSAN_FLAG} ${CMAKE_C_FLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS "${UBSAN_FLAG} ${CMAKE_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${UBSAN_FLAG} ${CMAKE_CXX_FLAGS}")
|
||||||
endif()
|
endif()
|
||||||
@ -43,7 +43,7 @@ endif()
|
|||||||
# For MSVC,
|
# For MSVC,
|
||||||
# 1. Replace /Zi and /ZI with /Z7
|
# 1. Replace /Zi and /ZI with /Z7
|
||||||
# 2. Switch off incremental linking in debug builds
|
# 2. Switch off incremental linking in debug builds
|
||||||
if (MSVC)
|
if(MSVC)
|
||||||
if(MSVC_Z7_OVERRIDE)
|
if(MSVC_Z7_OVERRIDE)
|
||||||
foreach(flag_var
|
foreach(flag_var
|
||||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||||
@ -66,14 +66,14 @@ endif(MSVC)
|
|||||||
|
|
||||||
# ---[ Threads
|
# ---[ Threads
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/public/threads.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/public/threads.cmake)
|
||||||
if (TARGET Threads::Threads)
|
if(TARGET Threads::Threads)
|
||||||
list(APPEND Caffe2_PUBLIC_DEPENDENCY_LIBS Threads::Threads)
|
list(APPEND Caffe2_PUBLIC_DEPENDENCY_LIBS Threads::Threads)
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"Cannot find threading library. Caffe2 requires Threads to compile.")
|
"Cannot find threading library. Caffe2 requires Threads to compile.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USE_TBB)
|
if(USE_TBB)
|
||||||
message(STATUS "Compiling TBB from source")
|
message(STATUS "Compiling TBB from source")
|
||||||
# Unset our restrictive C++ flags here and reset them later.
|
# Unset our restrictive C++ flags here and reset them later.
|
||||||
# Remove this once we use proper target_compile_options.
|
# Remove this once we use proper target_compile_options.
|
||||||
@ -151,14 +151,14 @@ else()
|
|||||||
message(FATAL_ERROR "Unrecognized BLAS option: " ${BLAS})
|
message(FATAL_ERROR "Unrecognized BLAS option: " ${BLAS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT INTERN_BUILD_MOBILE)
|
if(NOT INTERN_BUILD_MOBILE)
|
||||||
set(AT_MKL_ENABLED 0)
|
set(AT_MKL_ENABLED 0)
|
||||||
set(AT_MKL_MT 0)
|
set(AT_MKL_MT 0)
|
||||||
set(USE_BLAS 1)
|
set(USE_BLAS 1)
|
||||||
if(NOT (ATLAS_FOUND OR OpenBLAS_FOUND OR MKL_FOUND OR VECLIB_FOUND))
|
if(NOT (ATLAS_FOUND OR OpenBLAS_FOUND OR MKL_FOUND OR VECLIB_FOUND))
|
||||||
message(WARNING "Preferred BLAS (" ${BLAS} ") cannot be found, now searching for a general BLAS library")
|
message(WARNING "Preferred BLAS (" ${BLAS} ") cannot be found, now searching for a general BLAS library")
|
||||||
find_package(BLAS)
|
find_package(BLAS)
|
||||||
if (NOT BLAS_FOUND)
|
if(NOT BLAS_FOUND)
|
||||||
set(USE_BLAS 0)
|
set(USE_BLAS 0)
|
||||||
set(BLAS "" CACHE STRING "Selected BLAS library")
|
set(BLAS "" CACHE STRING "Selected BLAS library")
|
||||||
else()
|
else()
|
||||||
@ -166,12 +166,12 @@ if (NOT INTERN_BUILD_MOBILE)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MKL_FOUND)
|
if(MKL_FOUND)
|
||||||
ADD_DEFINITIONS(-DTH_BLAS_MKL)
|
ADD_DEFINITIONS(-DTH_BLAS_MKL)
|
||||||
if ("${MKL_THREADING}" STREQUAL "SEQ")
|
if("${MKL_THREADING}" STREQUAL "SEQ")
|
||||||
ADD_DEFINITIONS(-DTH_BLAS_MKL_SEQ=1)
|
ADD_DEFINITIONS(-DTH_BLAS_MKL_SEQ=1)
|
||||||
endif()
|
endif()
|
||||||
if (MSVC AND MKL_LIBRARIES MATCHES ".*libiomp5md\\.lib.*")
|
if(MSVC AND MKL_LIBRARIES MATCHES ".*libiomp5md\\.lib.*")
|
||||||
ADD_DEFINITIONS(-D_OPENMP_NOFORCE_MANIFEST)
|
ADD_DEFINITIONS(-D_OPENMP_NOFORCE_MANIFEST)
|
||||||
set(AT_MKL_MT 1)
|
set(AT_MKL_MT 1)
|
||||||
endif()
|
endif()
|
||||||
@ -186,22 +186,22 @@ endif()
|
|||||||
# mismatch between these shared dependencies, explicitly declare our intent to these
|
# mismatch between these shared dependencies, explicitly declare our intent to these
|
||||||
# libraries that we are interested in using the exact same source dependencies for all.
|
# libraries that we are interested in using the exact same source dependencies for all.
|
||||||
|
|
||||||
if (USE_NNPACK OR USE_QNNPACK OR USE_PYTORCH_QNNPACK OR USE_XNNPACK)
|
if(USE_NNPACK OR USE_QNNPACK OR USE_PYTORCH_QNNPACK OR USE_XNNPACK)
|
||||||
set(DISABLE_NNPACK_AND_FAMILY OFF)
|
set(DISABLE_NNPACK_AND_FAMILY OFF)
|
||||||
|
|
||||||
# Sanity checks - Can we actually build NNPACK and family given the configuration provided?
|
# Sanity checks - Can we actually build NNPACK and family given the configuration provided?
|
||||||
# Disable them and warn the user if not.
|
# Disable them and warn the user if not.
|
||||||
|
|
||||||
if (IOS)
|
if(IOS)
|
||||||
list(LENGTH IOS_ARCH IOS_ARCH_COUNT)
|
list(LENGTH IOS_ARCH IOS_ARCH_COUNT)
|
||||||
if (IOS_ARCH_COUNT GREATER 1)
|
if(IOS_ARCH_COUNT GREATER 1)
|
||||||
message(WARNING
|
message(WARNING
|
||||||
"Multi-architecture (${IOS_ARCH}) builds are not supported in {Q/X}NNPACK. "
|
"Multi-architecture (${IOS_ARCH}) builds are not supported in {Q/X}NNPACK. "
|
||||||
"Specify a single architecture in IOS_ARCH and re-configure, or "
|
"Specify a single architecture in IOS_ARCH and re-configure, or "
|
||||||
"turn this warning off by USE_{Q/X}NNPACK=OFF.")
|
"turn this warning off by USE_{Q/X}NNPACK=OFF.")
|
||||||
set(DISABLE_NNPACK_AND_FAMILY ON)
|
set(DISABLE_NNPACK_AND_FAMILY ON)
|
||||||
endif()
|
endif()
|
||||||
if (NOT IOS_ARCH MATCHES "^(i386|x86_64|armv7.*|arm64.*)$")
|
if(NOT IOS_ARCH MATCHES "^(i386|x86_64|armv7.*|arm64.*)$")
|
||||||
message(WARNING
|
message(WARNING
|
||||||
"Target architecture \"${IOS_ARCH}\" is not supported in {Q/X}NNPACK. "
|
"Target architecture \"${IOS_ARCH}\" is not supported in {Q/X}NNPACK. "
|
||||||
"Supported architectures are x86, x86-64, ARM, and ARM64. "
|
"Supported architectures are x86, x86-64, ARM, and ARM64. "
|
||||||
@ -209,14 +209,14 @@ if (USE_NNPACK OR USE_QNNPACK OR USE_PYTORCH_QNNPACK OR USE_XNNPACK)
|
|||||||
set(DISABLE_NNPACK_AND_FAMILY ON)
|
set(DISABLE_NNPACK_AND_FAMILY ON)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
if (NOT IOS AND NOT (CMAKE_SYSTEM_NAME MATCHES "^(Android|Linux|Darwin)$"))
|
if(NOT IOS AND NOT (CMAKE_SYSTEM_NAME MATCHES "^(Android|Linux|Darwin)$"))
|
||||||
message(WARNING
|
message(WARNING
|
||||||
"Target platform \"${CMAKE_SYSTEM_NAME}\" is not supported in {Q/X}NNPACK. "
|
"Target platform \"${CMAKE_SYSTEM_NAME}\" is not supported in {Q/X}NNPACK. "
|
||||||
"Supported platforms are Android, iOS, Linux, and macOS. "
|
"Supported platforms are Android, iOS, Linux, and macOS. "
|
||||||
"Turn this warning off by USE_{Q/X}NNPACK=OFF.")
|
"Turn this warning off by USE_{Q/X}NNPACK=OFF.")
|
||||||
set(DISABLE_NNPACK_AND_FAMILY ON)
|
set(DISABLE_NNPACK_AND_FAMILY ON)
|
||||||
endif()
|
endif()
|
||||||
if (NOT IOS AND NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "^(i686|AMD64|x86_64|armv[0-9].*|arm64|aarch64)$"))
|
if(NOT IOS AND NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "^(i686|AMD64|x86_64|armv[0-9].*|arm64|aarch64)$"))
|
||||||
message(WARNING
|
message(WARNING
|
||||||
"Target architecture \"${CMAKE_SYSTEM_PROCESSOR}\" is not supported in {Q/X}NNPACK. "
|
"Target architecture \"${CMAKE_SYSTEM_PROCESSOR}\" is not supported in {Q/X}NNPACK. "
|
||||||
"Supported architectures are x86, x86-64, ARM, and ARM64. "
|
"Supported architectures are x86, x86-64, ARM, and ARM64. "
|
||||||
@ -225,7 +225,7 @@ if (USE_NNPACK OR USE_QNNPACK OR USE_PYTORCH_QNNPACK OR USE_XNNPACK)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (DISABLE_NNPACK_AND_FAMILY)
|
if(DISABLE_NNPACK_AND_FAMILY)
|
||||||
set(USE_NNPACK OFF)
|
set(USE_NNPACK OFF)
|
||||||
set(USE_QNNPACK OFF)
|
set(USE_QNNPACK OFF)
|
||||||
set(USE_PYTORCH_QNNPACK OFF)
|
set(USE_PYTORCH_QNNPACK OFF)
|
||||||
@ -233,19 +233,19 @@ if (USE_NNPACK OR USE_QNNPACK OR USE_PYTORCH_QNNPACK OR USE_XNNPACK)
|
|||||||
else()
|
else()
|
||||||
set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
|
set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
|
||||||
|
|
||||||
if (NOT DEFINED CPUINFO_SOURCE_DIR)
|
if(NOT DEFINED CPUINFO_SOURCE_DIR)
|
||||||
set(CPUINFO_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/cpuinfo" CACHE STRING "cpuinfo source directory")
|
set(CPUINFO_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/cpuinfo" CACHE STRING "cpuinfo source directory")
|
||||||
endif()
|
endif()
|
||||||
if (NOT DEFINED FP16_SOURCE_DIR)
|
if(NOT DEFINED FP16_SOURCE_DIR)
|
||||||
set(FP16_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/FP16" CACHE STRING "FP16 source directory")
|
set(FP16_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/FP16" CACHE STRING "FP16 source directory")
|
||||||
endif()
|
endif()
|
||||||
if (NOT DEFINED FXDIV_SOURCE_DIR)
|
if(NOT DEFINED FXDIV_SOURCE_DIR)
|
||||||
set(FXDIV_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/FXdiv" CACHE STRING "FXdiv source directory")
|
set(FXDIV_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/FXdiv" CACHE STRING "FXdiv source directory")
|
||||||
endif()
|
endif()
|
||||||
if (NOT DEFINED PSIMD_SOURCE_DIR)
|
if(NOT DEFINED PSIMD_SOURCE_DIR)
|
||||||
set(PSIMD_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/psimd" CACHE STRING "PSimd source directory")
|
set(PSIMD_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/psimd" CACHE STRING "PSimd source directory")
|
||||||
endif()
|
endif()
|
||||||
if (NOT DEFINED PTHREADPOOL_SOURCE_DIR)
|
if(NOT DEFINED PTHREADPOOL_SOURCE_DIR)
|
||||||
set(PTHREADPOOL_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/pthreadpool" CACHE STRING "pthreadpool source directory")
|
set(PTHREADPOOL_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/pthreadpool" CACHE STRING "pthreadpool source directory")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -279,39 +279,39 @@ if(INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE AND (USE_QNNPACK OR USE_NNPAC
|
|||||||
set(PTHREADPOOL_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/pthreadpool" CACHE STRING "pthreadpool source directory")
|
set(PTHREADPOOL_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/pthreadpool" CACHE STRING "pthreadpool source directory")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
IF(NOT TARGET pthreadpool)
|
if(NOT TARGET pthreadpool)
|
||||||
SET(PTHREADPOOL_BUILD_TESTS OFF CACHE BOOL "")
|
SET(PTHREADPOOL_BUILD_TESTS OFF CACHE BOOL "")
|
||||||
SET(PTHREADPOOL_BUILD_BENCHMARKS OFF CACHE BOOL "")
|
SET(PTHREADPOOL_BUILD_BENCHMARKS OFF CACHE BOOL "")
|
||||||
ADD_SUBDIRECTORY(
|
ADD_SUBDIRECTORY(
|
||||||
"${PTHREADPOOL_SOURCE_DIR}"
|
"${PTHREADPOOL_SOURCE_DIR}"
|
||||||
"${CONFU_DEPENDENCIES_BINARY_DIR}/pthreadpool"
|
"${CONFU_DEPENDENCIES_BINARY_DIR}/pthreadpool"
|
||||||
EXCLUDE_FROM_ALL)
|
EXCLUDE_FROM_ALL)
|
||||||
ENDIF()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# XNNPACK has not option of like QNNPACK_CUSTOM_THREADPOOL
|
# XNNPACK has not option of like QNNPACK_CUSTOM_THREADPOOL
|
||||||
# that allows us to hijack pthreadpool interface.
|
# that allows us to hijack pthreadpool interface.
|
||||||
# Thus not doing this ends up building pthreadpool as well as
|
# Thus not doing this ends up building pthreadpool as well as
|
||||||
# the internal implemenation of pthreadpool which results in symbol conflicts.
|
# the internal implemenation of pthreadpool which results in symbol conflicts.
|
||||||
if (USE_XNNPACK)
|
if(USE_XNNPACK)
|
||||||
if(NOT DEFINED PTHREADPOOL_SOURCE_DIR)
|
if(NOT DEFINED PTHREADPOOL_SOURCE_DIR)
|
||||||
set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
|
set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
|
||||||
set(PTHREADPOOL_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/pthreadpool" CACHE STRING "pthreadpool source directory")
|
set(PTHREADPOOL_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/pthreadpool" CACHE STRING "pthreadpool source directory")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
IF(NOT TARGET pthreadpool)
|
if(NOT TARGET pthreadpool)
|
||||||
SET(PTHREADPOOL_BUILD_TESTS OFF CACHE BOOL "")
|
SET(PTHREADPOOL_BUILD_TESTS OFF CACHE BOOL "")
|
||||||
SET(PTHREADPOOL_BUILD_BENCHMARKS OFF CACHE BOOL "")
|
SET(PTHREADPOOL_BUILD_BENCHMARKS OFF CACHE BOOL "")
|
||||||
ADD_SUBDIRECTORY(
|
ADD_SUBDIRECTORY(
|
||||||
"${PTHREADPOOL_SOURCE_DIR}"
|
"${PTHREADPOOL_SOURCE_DIR}"
|
||||||
"${CONFU_DEPENDENCIES_BINARY_DIR}/pthreadpool"
|
"${CONFU_DEPENDENCIES_BINARY_DIR}/pthreadpool"
|
||||||
EXCLUDE_FROM_ALL)
|
EXCLUDE_FROM_ALL)
|
||||||
ENDIF()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ---[ Caffe2 uses cpuinfo library in the thread pool
|
# ---[ Caffe2 uses cpuinfo library in the thread pool
|
||||||
if (NOT TARGET cpuinfo)
|
if(NOT TARGET cpuinfo)
|
||||||
if (NOT DEFINED CPUINFO_SOURCE_DIR)
|
if(NOT DEFINED CPUINFO_SOURCE_DIR)
|
||||||
set(CPUINFO_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../third_party/cpuinfo" CACHE STRING "cpuinfo source directory")
|
set(CPUINFO_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../third_party/cpuinfo" CACHE STRING "cpuinfo source directory")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ if (NOT TARGET cpuinfo)
|
|||||||
set(CPUINFO_LIBRARY_TYPE "static" CACHE STRING "")
|
set(CPUINFO_LIBRARY_TYPE "static" CACHE STRING "")
|
||||||
set(CPUINFO_LOG_LEVEL "error" CACHE STRING "")
|
set(CPUINFO_LOG_LEVEL "error" CACHE STRING "")
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
if (CAFFE2_USE_MSVC_STATIC_RUNTIME)
|
if(CAFFE2_USE_MSVC_STATIC_RUNTIME)
|
||||||
set(CPUINFO_RUNTIME_TYPE "static" CACHE STRING "")
|
set(CPUINFO_RUNTIME_TYPE "static" CACHE STRING "")
|
||||||
else()
|
else()
|
||||||
set(CPUINFO_RUNTIME_TYPE "shared" CACHE STRING "")
|
set(CPUINFO_RUNTIME_TYPE "shared" CACHE STRING "")
|
||||||
@ -343,7 +343,7 @@ list(APPEND Caffe2_DEPENDENCY_LIBS cpuinfo)
|
|||||||
if(USE_QNNPACK)
|
if(USE_QNNPACK)
|
||||||
set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
|
set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party")
|
||||||
|
|
||||||
if (NOT DEFINED QNNPACK_SOURCE_DIR)
|
if(NOT DEFINED QNNPACK_SOURCE_DIR)
|
||||||
set(QNNPACK_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/QNNPACK" CACHE STRING "QNNPACK source directory")
|
set(QNNPACK_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/QNNPACK" CACHE STRING "QNNPACK source directory")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -374,7 +374,7 @@ endif()
|
|||||||
|
|
||||||
# ---[ PYTORCH_QNNPACK
|
# ---[ PYTORCH_QNNPACK
|
||||||
if(USE_PYTORCH_QNNPACK)
|
if(USE_PYTORCH_QNNPACK)
|
||||||
if (NOT DEFINED PYTORCH_QNNPACK_SOURCE_DIR)
|
if(NOT DEFINED PYTORCH_QNNPACK_SOURCE_DIR)
|
||||||
set(PYTORCH_QNNPACK_SOURCE_DIR "${PROJECT_SOURCE_DIR}/aten/src/ATen/native/quantized/cpu/qnnpack" CACHE STRING "QNNPACK source directory")
|
set(PYTORCH_QNNPACK_SOURCE_DIR "${PROJECT_SOURCE_DIR}/aten/src/ATen/native/quantized/cpu/qnnpack" CACHE STRING "QNNPACK source directory")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -415,11 +415,11 @@ endif()
|
|||||||
|
|
||||||
# ---[ XNNPACK
|
# ---[ XNNPACK
|
||||||
if(USE_XNNPACK)
|
if(USE_XNNPACK)
|
||||||
if (NOT DEFINED XNNPACK_SOURCE_DIR)
|
if(NOT DEFINED XNNPACK_SOURCE_DIR)
|
||||||
set(XNNPACK_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/XNNPACK" CACHE STRING "XNNPACK source directory")
|
set(XNNPACK_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/XNNPACK" CACHE STRING "XNNPACK source directory")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT DEFINED XNNPACK_INCLUDE_DIR)
|
if(NOT DEFINED XNNPACK_INCLUDE_DIR)
|
||||||
set(XNNPACK_INCLUDE_DIR "${XNNPACK_SOURCE_DIR}/include" CACHE STRING "XNNPACK include directory")
|
set(XNNPACK_INCLUDE_DIR "${XNNPACK_SOURCE_DIR}/include" CACHE STRING "XNNPACK include directory")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -452,7 +452,7 @@ endif()
|
|||||||
# ---[ gflags
|
# ---[ gflags
|
||||||
if(USE_GFLAGS)
|
if(USE_GFLAGS)
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/public/gflags.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/public/gflags.cmake)
|
||||||
if (NOT TARGET gflags)
|
if(NOT TARGET gflags)
|
||||||
message(WARNING
|
message(WARNING
|
||||||
"gflags is not found. Caffe2 will build without gflags support but "
|
"gflags is not found. Caffe2 will build without gflags support but "
|
||||||
"it is strongly recommended that you install gflags. Suppress this "
|
"it is strongly recommended that you install gflags. Suppress this "
|
||||||
@ -464,7 +464,7 @@ endif()
|
|||||||
# ---[ Google-glog
|
# ---[ Google-glog
|
||||||
if(USE_GLOG)
|
if(USE_GLOG)
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/public/glog.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/public/glog.cmake)
|
||||||
if (TARGET glog::glog)
|
if(TARGET glog::glog)
|
||||||
set(CAFFE2_USE_GOOGLE_GLOG 1)
|
set(CAFFE2_USE_GOOGLE_GLOG 1)
|
||||||
include_directories(SYSTEM ${GLOG_INCLUDE_DIR})
|
include_directories(SYSTEM ${GLOG_INCLUDE_DIR})
|
||||||
list(APPEND Caffe2_PUBLIC_DEPENDENCY_LIBS glog::glog)
|
list(APPEND Caffe2_PUBLIC_DEPENDENCY_LIBS glog::glog)
|
||||||
@ -491,13 +491,13 @@ if(BUILD_TEST)
|
|||||||
set(INSTALL_GTEST OFF CACHE BOOL "Install gtest." FORCE)
|
set(INSTALL_GTEST OFF CACHE BOOL "Install gtest." FORCE)
|
||||||
set(BUILD_GMOCK ON CACHE BOOL "Build gmock." FORCE)
|
set(BUILD_GMOCK ON CACHE BOOL "Build gmock." FORCE)
|
||||||
# For Windows, we will check the runtime used is correctly passed in.
|
# For Windows, we will check the runtime used is correctly passed in.
|
||||||
if (NOT CAFFE2_USE_MSVC_STATIC_RUNTIME)
|
if(NOT CAFFE2_USE_MSVC_STATIC_RUNTIME)
|
||||||
set(gtest_force_shared_crt ON CACHE BOOL "force shared crt on gtest" FORCE)
|
set(gtest_force_shared_crt ON CACHE BOOL "force shared crt on gtest" FORCE)
|
||||||
endif()
|
endif()
|
||||||
# We need to replace googletest cmake scripts too.
|
# We need to replace googletest cmake scripts too.
|
||||||
# Otherwise, it will sometimes break the build.
|
# Otherwise, it will sometimes break the build.
|
||||||
# To make the git clean after the build, we make a backup first.
|
# To make the git clean after the build, we make a backup first.
|
||||||
if (MSVC AND MSVC_Z7_OVERRIDE)
|
if(MSVC AND MSVC_Z7_OVERRIDE)
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
"-DFILENAME=${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googletest/cmake/internal_utils.cmake"
|
"-DFILENAME=${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googletest/cmake/internal_utils.cmake"
|
||||||
@ -537,7 +537,7 @@ if(BUILD_TEST)
|
|||||||
set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
|
set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
|
||||||
|
|
||||||
# To make the git clean after the build, we revert the changes here.
|
# To make the git clean after the build, we revert the changes here.
|
||||||
if (MSVC AND MSVC_Z7_OVERRIDE)
|
if(MSVC AND MSVC_Z7_OVERRIDE)
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND ${CMAKE_COMMAND}
|
COMMAND ${CMAKE_COMMAND}
|
||||||
"-DFILENAME=${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googletest/cmake/internal_utils.cmake"
|
"-DFILENAME=${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googletest/cmake/internal_utils.cmake"
|
||||||
@ -606,7 +606,7 @@ if(USE_LMDB)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USE_OPENCL)
|
if(USE_OPENCL)
|
||||||
message(INFO "USING OPENCL")
|
message(INFO "USING OPENCL")
|
||||||
find_package(OpenCL REQUIRED)
|
find_package(OpenCL REQUIRED)
|
||||||
include_directories(SYSTEM ${OpenCL_INCLUDE_DIRS})
|
include_directories(SYSTEM ${OpenCL_INCLUDE_DIRS})
|
||||||
@ -687,7 +687,7 @@ if(USE_OPENCV)
|
|||||||
if(OpenCV_FOUND)
|
if(OpenCV_FOUND)
|
||||||
include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS})
|
include_directories(SYSTEM ${OpenCV_INCLUDE_DIRS})
|
||||||
list(APPEND Caffe2_DEPENDENCY_LIBS ${OpenCV_LIBS})
|
list(APPEND Caffe2_DEPENDENCY_LIBS ${OpenCV_LIBS})
|
||||||
if (MSVC AND USE_CUDA)
|
if(MSVC AND USE_CUDA)
|
||||||
list(APPEND Caffe2_CUDA_DEPENDENCY_LIBS ${OpenCV_LIBS})
|
list(APPEND Caffe2_CUDA_DEPENDENCY_LIBS ${OpenCV_LIBS})
|
||||||
endif()
|
endif()
|
||||||
message(STATUS "OpenCV found (${OpenCV_CONFIG_PATH})")
|
message(STATUS "OpenCV found (${OpenCV_CONFIG_PATH})")
|
||||||
@ -700,19 +700,19 @@ endif()
|
|||||||
# ---[ FFMPEG
|
# ---[ FFMPEG
|
||||||
if(USE_FFMPEG)
|
if(USE_FFMPEG)
|
||||||
find_package(FFmpeg REQUIRED)
|
find_package(FFmpeg REQUIRED)
|
||||||
if (FFMPEG_FOUND)
|
if(FFMPEG_FOUND)
|
||||||
message("Found FFMPEG/LibAV libraries")
|
message("Found FFMPEG/LibAV libraries")
|
||||||
include_directories(SYSTEM ${FFMPEG_INCLUDE_DIR})
|
include_directories(SYSTEM ${FFMPEG_INCLUDE_DIR})
|
||||||
list(APPEND Caffe2_DEPENDENCY_LIBS ${FFMPEG_LIBRARIES})
|
list(APPEND Caffe2_DEPENDENCY_LIBS ${FFMPEG_LIBRARIES})
|
||||||
else ()
|
else()
|
||||||
message("Not compiling with FFmpeg. Suppress this warning with -DUSE_FFMPEG=OFF")
|
message("Not compiling with FFmpeg. Suppress this warning with -DUSE_FFMPEG=OFF")
|
||||||
caffe2_update_option(USE_FFMPEG OFF)
|
caffe2_update_option(USE_FFMPEG OFF)
|
||||||
endif ()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ---[ Caffe2 depends on FP16 library for half-precision conversions
|
# ---[ Caffe2 depends on FP16 library for half-precision conversions
|
||||||
if (NOT TARGET fp16)
|
if(NOT TARGET fp16)
|
||||||
if (NOT DEFINED FP16_SOURCE_DIR)
|
if(NOT DEFINED FP16_SOURCE_DIR)
|
||||||
set(FP16_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../third_party/FP16" CACHE STRING "FP16 source directory")
|
set(FP16_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../third_party/FP16" CACHE STRING "FP16 source directory")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -727,7 +727,7 @@ list(APPEND Caffe2_DEPENDENCY_LIBS fp16)
|
|||||||
# ---[ EIGEN
|
# ---[ EIGEN
|
||||||
# Due to license considerations, we will only use the MPL2 parts of Eigen.
|
# Due to license considerations, we will only use the MPL2 parts of Eigen.
|
||||||
set(EIGEN_MPL2_ONLY 1)
|
set(EIGEN_MPL2_ONLY 1)
|
||||||
if (USE_SYSTEM_EIGEN_INSTALL)
|
if(USE_SYSTEM_EIGEN_INSTALL)
|
||||||
find_package(Eigen3)
|
find_package(Eigen3)
|
||||||
if(EIGEN3_FOUND)
|
if(EIGEN3_FOUND)
|
||||||
message(STATUS "Found system Eigen at " ${EIGEN3_INCLUDE_DIR})
|
message(STATUS "Found system Eigen at " ${EIGEN3_INCLUDE_DIR})
|
||||||
@ -749,7 +749,7 @@ if(BUILD_PYTHON)
|
|||||||
execute_process(
|
execute_process(
|
||||||
COMMAND "which" "python" RESULT_VARIABLE _exitcode OUTPUT_VARIABLE _py_exe)
|
COMMAND "which" "python" RESULT_VARIABLE _exitcode OUTPUT_VARIABLE _py_exe)
|
||||||
if(${_exitcode} EQUAL 0)
|
if(${_exitcode} EQUAL 0)
|
||||||
if (NOT MSVC)
|
if(NOT MSVC)
|
||||||
string(STRIP ${_py_exe} PYTHON_EXECUTABLE)
|
string(STRIP ${_py_exe} PYTHON_EXECUTABLE)
|
||||||
endif()
|
endif()
|
||||||
message(STATUS "Setting Python to ${PYTHON_EXECUTABLE}")
|
message(STATUS "Setting Python to ${PYTHON_EXECUTABLE}")
|
||||||
@ -790,7 +790,7 @@ if(BUILD_PYTHON)
|
|||||||
pycmd_no_exit(_py_lib _exitcode "from sysconfig import get_paths; print(get_paths()['stdlib'])")
|
pycmd_no_exit(_py_lib _exitcode "from sysconfig import get_paths; print(get_paths()['stdlib'])")
|
||||||
if("${_exitcode}" EQUAL 0 AND EXISTS "${_py_lib}" AND EXISTS "${_py_lib}")
|
if("${_exitcode}" EQUAL 0 AND EXISTS "${_py_lib}" AND EXISTS "${_py_lib}")
|
||||||
SET(PYTHON_LIBRARY "${_py_lib}")
|
SET(PYTHON_LIBRARY "${_py_lib}")
|
||||||
if (MSVC)
|
if(MSVC)
|
||||||
STRING(REPLACE "Lib" "libs" _py_static_lib ${_py_lib})
|
STRING(REPLACE "Lib" "libs" _py_static_lib ${_py_lib})
|
||||||
link_directories(${_py_static_lib})
|
link_directories(${_py_static_lib})
|
||||||
endif()
|
endif()
|
||||||
@ -806,7 +806,7 @@ if(BUILD_PYTHON)
|
|||||||
|
|
||||||
# When building pytorch, we pass this in directly from setup.py, and
|
# When building pytorch, we pass this in directly from setup.py, and
|
||||||
# don't want to overwrite it because we trust python more than cmake
|
# don't want to overwrite it because we trust python more than cmake
|
||||||
if (NUMPY_INCLUDE_DIR)
|
if(NUMPY_INCLUDE_DIR)
|
||||||
set(NUMPY_FOUND ON)
|
set(NUMPY_FOUND ON)
|
||||||
elseif(USE_NUMPY)
|
elseif(USE_NUMPY)
|
||||||
find_package(NumPy)
|
find_package(NumPy)
|
||||||
@ -885,31 +885,31 @@ if(USE_OPENMP)
|
|||||||
SET(WITH_OPENMP ON CACHE BOOL "OpenMP support if available?")
|
SET(WITH_OPENMP ON CACHE BOOL "OpenMP support if available?")
|
||||||
|
|
||||||
# macOS + GCC
|
# macOS + GCC
|
||||||
IF (APPLE AND CMAKE_COMPILER_IS_GNUCC)
|
if(APPLE AND CMAKE_COMPILER_IS_GNUCC)
|
||||||
EXEC_PROGRAM (uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION)
|
EXEC_PROGRAM (uname ARGS -v OUTPUT_VARIABLE DARWIN_VERSION)
|
||||||
STRING (REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
|
STRING (REGEX MATCH "[0-9]+" DARWIN_VERSION ${DARWIN_VERSION})
|
||||||
MESSAGE (STATUS "macOS Darwin version: ${DARWIN_VERSION}")
|
MESSAGE (STATUS "macOS Darwin version: ${DARWIN_VERSION}")
|
||||||
IF (DARWIN_VERSION GREATER 9)
|
if(DARWIN_VERSION GREATER 9)
|
||||||
SET(APPLE_OPENMP_SUCKS 1)
|
SET(APPLE_OPENMP_SUCKS 1)
|
||||||
ENDIF (DARWIN_VERSION GREATER 9)
|
endif(DARWIN_VERSION GREATER 9)
|
||||||
EXECUTE_PROCESS (COMMAND ${CMAKE_C_COMPILER} -dumpversion
|
EXECUTE_PROCESS (COMMAND ${CMAKE_C_COMPILER} -dumpversion
|
||||||
OUTPUT_VARIABLE GCC_VERSION)
|
OUTPUT_VARIABLE GCC_VERSION)
|
||||||
IF (APPLE_OPENMP_SUCKS AND GCC_VERSION VERSION_LESS 4.6.2)
|
if(APPLE_OPENMP_SUCKS AND GCC_VERSION VERSION_LESS 4.6.2)
|
||||||
MESSAGE(WARNING "Disabling OpenMP (unstable with this version of GCC). "
|
MESSAGE(WARNING "Disabling OpenMP (unstable with this version of GCC). "
|
||||||
"Install GCC >= 4.6.2 or change your OS to enable OpenMP.")
|
"Install GCC >= 4.6.2 or change your OS to enable OpenMP.")
|
||||||
add_compile_options(-Wno-unknown-pragmas)
|
add_compile_options(-Wno-unknown-pragmas)
|
||||||
SET(WITH_OPENMP OFF CACHE BOOL "OpenMP support if available?" FORCE)
|
SET(WITH_OPENMP OFF CACHE BOOL "OpenMP support if available?" FORCE)
|
||||||
ENDIF()
|
endif()
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF("${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC"
|
if("${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC"
|
||||||
AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
MESSAGE(STATUS "Setting OpenMP flags for clang-cl")
|
MESSAGE(STATUS "Setting OpenMP flags for clang-cl")
|
||||||
SET(OpenMP_CXX_FLAGS "-Xclang -fopenmp")
|
SET(OpenMP_CXX_FLAGS "-Xclang -fopenmp")
|
||||||
SET(OpenMP_C_FLAGS "-Xclang -fopenmp")
|
SET(OpenMP_C_FLAGS "-Xclang -fopenmp")
|
||||||
SET(CHECKED_OPENMP ON CACHE BOOL "already checked for OpenMP")
|
SET(CHECKED_OPENMP ON CACHE BOOL "already checked for OpenMP")
|
||||||
SET(OPENMP_FOUND ON CACHE BOOL "OpenMP Support found")
|
SET(OPENMP_FOUND ON CACHE BOOL "OpenMP Support found")
|
||||||
if (NOT MKL_FOUND)
|
if(NOT MKL_FOUND)
|
||||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_version_output)
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_version_output)
|
||||||
string (REGEX REPLACE ".*InstalledDir: ([^\n]+).*" "\\1" CLANG_BINDIR ${clang_version_output})
|
string (REGEX REPLACE ".*InstalledDir: ([^\n]+).*" "\\1" CLANG_BINDIR ${clang_version_output})
|
||||||
|
|
||||||
@ -926,24 +926,24 @@ if(USE_OPENMP)
|
|||||||
|
|
||||||
LIST(APPEND Caffe2_PUBLIC_DEPENDENCY_LIBS caffe2::openmp)
|
LIST(APPEND Caffe2_PUBLIC_DEPENDENCY_LIBS caffe2::openmp)
|
||||||
endif()
|
endif()
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF (WITH_OPENMP AND NOT CHECKED_OPENMP)
|
if(WITH_OPENMP AND NOT CHECKED_OPENMP)
|
||||||
FIND_PACKAGE(OpenMP QUIET)
|
FIND_PACKAGE(OpenMP QUIET)
|
||||||
SET(CHECKED_OPENMP ON CACHE BOOL "already checked for OpenMP")
|
SET(CHECKED_OPENMP ON CACHE BOOL "already checked for OpenMP")
|
||||||
|
|
||||||
# OPENMP_FOUND is not cached in FindOpenMP.cmake (all other variables are cached)
|
# OPENMP_FOUND is not cached in FindOpenMP.cmake (all other variables are cached)
|
||||||
# see https://github.com/Kitware/CMake/blob/master/Modules/FindOpenMP.cmake
|
# see https://github.com/Kitware/CMake/blob/master/Modules/FindOpenMP.cmake
|
||||||
SET(OPENMP_FOUND ${OPENMP_FOUND} CACHE BOOL "OpenMP Support found")
|
SET(OPENMP_FOUND ${OPENMP_FOUND} CACHE BOOL "OpenMP Support found")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
if(OPENMP_FOUND)
|
if(OPENMP_FOUND)
|
||||||
message(STATUS "Adding OpenMP CXX_FLAGS: " ${OpenMP_CXX_FLAGS})
|
message(STATUS "Adding OpenMP CXX_FLAGS: " ${OpenMP_CXX_FLAGS})
|
||||||
IF("${OpenMP_CXX_LIBRARIES}" STREQUAL "")
|
if("${OpenMP_CXX_LIBRARIES}" STREQUAL "")
|
||||||
message(STATUS "No OpenMP library needs to be linked against")
|
message(STATUS "No OpenMP library needs to be linked against")
|
||||||
ELSE()
|
else()
|
||||||
message(STATUS "Will link against OpenMP libraries: ${OpenMP_CXX_LIBRARIES}")
|
message(STATUS "Will link against OpenMP libraries: ${OpenMP_CXX_LIBRARIES}")
|
||||||
ENDIF()
|
endif()
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||||
else()
|
else()
|
||||||
@ -959,18 +959,18 @@ if(ANDROID)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ---[ LLVM
|
# ---[ LLVM
|
||||||
if (USE_LLVM)
|
if(USE_LLVM)
|
||||||
message(STATUS "Looking for LLVM in ${USE_LLVM}")
|
message(STATUS "Looking for LLVM in ${USE_LLVM}")
|
||||||
find_package(LLVM QUIET PATHS ${USE_LLVM} NO_DEFAULT_PATH)
|
find_package(LLVM QUIET PATHS ${USE_LLVM} NO_DEFAULT_PATH)
|
||||||
|
|
||||||
if (LLVM_FOUND)
|
if(LLVM_FOUND)
|
||||||
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
|
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
|
||||||
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
|
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
|
||||||
|
|
||||||
include_directories(${LLVM_INCLUDE_DIRS})
|
include_directories(${LLVM_INCLUDE_DIRS})
|
||||||
add_definitions(-DTORCH_ENABLE_LLVM ${LLVM_DEFINITIONS})
|
add_definitions(-DTORCH_ENABLE_LLVM ${LLVM_DEFINITIONS})
|
||||||
endif (LLVM_FOUND)
|
endif(LLVM_FOUND)
|
||||||
endif (USE_LLVM)
|
endif(USE_LLVM)
|
||||||
|
|
||||||
# ---[ CUDA
|
# ---[ CUDA
|
||||||
if(USE_CUDA)
|
if(USE_CUDA)
|
||||||
@ -1023,7 +1023,7 @@ if(USE_ROCM)
|
|||||||
message(INFO "Compiling with HIP for AMD.")
|
message(INFO "Compiling with HIP for AMD.")
|
||||||
caffe2_update_option(USE_ROCM ON)
|
caffe2_update_option(USE_ROCM ON)
|
||||||
|
|
||||||
if (USE_NCCL AND NOT USE_SYSTEM_NCCL)
|
if(USE_NCCL AND NOT USE_SYSTEM_NCCL)
|
||||||
message(INFO "Forcing USE_SYSTEM_NCCL to ON since it's required by using RCCL")
|
message(INFO "Forcing USE_SYSTEM_NCCL to ON since it's required by using RCCL")
|
||||||
caffe2_update_option(USE_SYSTEM_NCCL ON)
|
caffe2_update_option(USE_SYSTEM_NCCL ON)
|
||||||
endif()
|
endif()
|
||||||
@ -1166,8 +1166,8 @@ if(USE_PROF)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USE_SNPE AND ANDROID)
|
if(USE_SNPE AND ANDROID)
|
||||||
if (SNPE_LOCATION AND SNPE_HEADERS)
|
if(SNPE_LOCATION AND SNPE_HEADERS)
|
||||||
message(STATUS "Using SNPE location specified by -DSNPE_LOCATION: " ${SNPE_LOCATION})
|
message(STATUS "Using SNPE location specified by -DSNPE_LOCATION: " ${SNPE_LOCATION})
|
||||||
message(STATUS "Using SNPE headers specified by -DSNPE_HEADERS: " ${SNPE_HEADERS})
|
message(STATUS "Using SNPE headers specified by -DSNPE_HEADERS: " ${SNPE_HEADERS})
|
||||||
include_directories(SYSTEM ${SNPE_HEADERS})
|
include_directories(SYSTEM ${SNPE_HEADERS})
|
||||||
@ -1179,29 +1179,29 @@ if (USE_SNPE AND ANDROID)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USE_METAL)
|
if(USE_METAL)
|
||||||
if (NOT IOS)
|
if(NOT IOS)
|
||||||
message(WARNING "Metal is only used in ios builds.")
|
message(WARNING "Metal is only used in ios builds.")
|
||||||
caffe2_update_option(USE_METAL OFF)
|
caffe2_update_option(USE_METAL OFF)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USE_NNAPI AND NOT ANDROID)
|
if(USE_NNAPI AND NOT ANDROID)
|
||||||
message(WARNING "NNApi is only used in android builds.")
|
message(WARNING "NNApi is only used in android builds.")
|
||||||
caffe2_update_option(USE_NNAPI OFF)
|
caffe2_update_option(USE_NNAPI OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT INTERN_BUILD_MOBILE AND BUILD_CAFFE2_OPS)
|
if(NOT INTERN_BUILD_MOBILE AND BUILD_CAFFE2_OPS)
|
||||||
if (CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
|
if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
|
||||||
list(APPEND Caffe2_DEPENDENCY_LIBS aten_op_header_gen)
|
list(APPEND Caffe2_DEPENDENCY_LIBS aten_op_header_gen)
|
||||||
if (USE_CUDA)
|
if(USE_CUDA)
|
||||||
list(APPEND Caffe2_CUDA_DEPENDENCY_LIBS aten_op_header_gen)
|
list(APPEND Caffe2_CUDA_DEPENDENCY_LIBS aten_op_header_gen)
|
||||||
endif()
|
endif()
|
||||||
include_directories(${PROJECT_BINARY_DIR}/caffe2/contrib/aten)
|
include_directories(${PROJECT_BINARY_DIR}/caffe2/contrib/aten)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USE_ZSTD)
|
if(USE_ZSTD)
|
||||||
list(APPEND Caffe2_DEPENDENCY_LIBS libzstd_static)
|
list(APPEND Caffe2_DEPENDENCY_LIBS libzstd_static)
|
||||||
include_directories(SYSTEM ${CMAKE_CURRENT_LIST_DIR}/../third_party/zstd/lib)
|
include_directories(SYSTEM ${CMAKE_CURRENT_LIST_DIR}/../third_party/zstd/lib)
|
||||||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/zstd/build/cmake)
|
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/zstd/build/cmake)
|
||||||
@ -1209,7 +1209,7 @@ if (USE_ZSTD)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ---[ Onnx
|
# ---[ Onnx
|
||||||
if (CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
|
if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
|
||||||
if(EXISTS "${CAFFE2_CUSTOM_PROTOC_EXECUTABLE}")
|
if(EXISTS "${CAFFE2_CUSTOM_PROTOC_EXECUTABLE}")
|
||||||
set(ONNX_CUSTOM_PROTOC_EXECUTABLE ${CAFFE2_CUSTOM_PROTOC_EXECUTABLE})
|
set(ONNX_CUSTOM_PROTOC_EXECUTABLE ${CAFFE2_CUSTOM_PROTOC_EXECUTABLE})
|
||||||
endif()
|
endif()
|
||||||
@ -1220,10 +1220,10 @@ if (CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
|
|||||||
# If linking local protobuf, make sure ONNX has the same protobuf
|
# If linking local protobuf, make sure ONNX has the same protobuf
|
||||||
# patches as Caffe2 and Caffe proto. This forces some functions to
|
# patches as Caffe2 and Caffe proto. This forces some functions to
|
||||||
# not be inline and instead route back to the statically-linked protobuf.
|
# not be inline and instead route back to the statically-linked protobuf.
|
||||||
if (CAFFE2_LINK_LOCAL_PROTOBUF)
|
if(CAFFE2_LINK_LOCAL_PROTOBUF)
|
||||||
set(ONNX_PROTO_POST_BUILD_SCRIPT ${PROJECT_SOURCE_DIR}/cmake/ProtoBufPatch.cmake)
|
set(ONNX_PROTO_POST_BUILD_SCRIPT ${PROJECT_SOURCE_DIR}/cmake/ProtoBufPatch.cmake)
|
||||||
endif()
|
endif()
|
||||||
if (ONNX_ML)
|
if(ONNX_ML)
|
||||||
add_definitions(-DONNX_ML=1)
|
add_definitions(-DONNX_ML=1)
|
||||||
endif()
|
endif()
|
||||||
# Add op schemas in "ai.onnx.pytorch" domain
|
# Add op schemas in "ai.onnx.pytorch" domain
|
||||||
@ -1236,7 +1236,7 @@ if (CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
|
|||||||
add_definitions(-DONNX_NAMESPACE=${ONNX_NAMESPACE})
|
add_definitions(-DONNX_NAMESPACE=${ONNX_NAMESPACE})
|
||||||
# In mobile build we care about code size, and so we need drop
|
# In mobile build we care about code size, and so we need drop
|
||||||
# everything (e.g. checker, optimizer) in onnx but the pb definition.
|
# everything (e.g. checker, optimizer) in onnx but the pb definition.
|
||||||
if (ANDROID OR IOS)
|
if(ANDROID OR IOS)
|
||||||
caffe2_interface_library(onnx_proto onnx_library)
|
caffe2_interface_library(onnx_proto onnx_library)
|
||||||
else()
|
else()
|
||||||
caffe2_interface_library(onnx onnx_library)
|
caffe2_interface_library(onnx onnx_library)
|
||||||
@ -1253,15 +1253,15 @@ function (add_onnx_tensorrt_subdir)
|
|||||||
set(CUDNN_INCLUDE_DIR "${CUDNN_INCLUDE_PATH}")
|
set(CUDNN_INCLUDE_DIR "${CUDNN_INCLUDE_PATH}")
|
||||||
set(CUDNN_LIBRARY "${CUDNN_LIBRARY_PATH}")
|
set(CUDNN_LIBRARY "${CUDNN_LIBRARY_PATH}")
|
||||||
set(CMAKE_VERSION_ORIG "{CMAKE_VERSION}")
|
set(CMAKE_VERSION_ORIG "{CMAKE_VERSION}")
|
||||||
if (FIND_CUDA_MODULE_DEPRECATED)
|
if(FIND_CUDA_MODULE_DEPRECATED)
|
||||||
# TODO: this WAR is for https://github.com/pytorch/pytorch/issues/18524
|
# TODO: this WAR is for https://github.com/pytorch/pytorch/issues/18524
|
||||||
set(CMAKE_VERSION "3.9.0")
|
set(CMAKE_VERSION "3.9.0")
|
||||||
endif()
|
endif()
|
||||||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/onnx-tensorrt EXCLUDE_FROM_ALL)
|
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/onnx-tensorrt EXCLUDE_FROM_ALL)
|
||||||
set(CMAKE_VERSION "{CMAKE_VERSION_ORIG}")
|
set(CMAKE_VERSION "{CMAKE_VERSION_ORIG}")
|
||||||
endfunction()
|
endfunction()
|
||||||
if (CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
|
if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
|
||||||
if (USE_TENSORRT)
|
if(USE_TENSORRT)
|
||||||
set(CMAKE_CUDA_COMPILER ${CUDA_NVCC_EXECUTABLE})
|
set(CMAKE_CUDA_COMPILER ${CUDA_NVCC_EXECUTABLE})
|
||||||
add_onnx_tensorrt_subdir()
|
add_onnx_tensorrt_subdir()
|
||||||
include_directories("${CMAKE_CURRENT_LIST_DIR}/../third_party/onnx-tensorrt")
|
include_directories("${CMAKE_CURRENT_LIST_DIR}/../third_party/onnx-tensorrt")
|
||||||
@ -1272,7 +1272,7 @@ if (CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# --[ ATen checks
|
# --[ ATen checks
|
||||||
if (NOT INTERN_BUILD_MOBILE)
|
if(NOT INTERN_BUILD_MOBILE)
|
||||||
set(TORCH_CUDA_ARCH_LIST $ENV{TORCH_CUDA_ARCH_LIST})
|
set(TORCH_CUDA_ARCH_LIST $ENV{TORCH_CUDA_ARCH_LIST})
|
||||||
set(TORCH_NVCC_FLAGS $ENV{TORCH_NVCC_FLAGS})
|
set(TORCH_NVCC_FLAGS $ENV{TORCH_NVCC_FLAGS})
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||||
@ -1290,63 +1290,63 @@ if (NOT INTERN_BUILD_MOBILE)
|
|||||||
# this, but since FindCUDA upstream is subsumed by first-class support
|
# this, but since FindCUDA upstream is subsumed by first-class support
|
||||||
# for CUDA language, it seemed not worth fixing.
|
# for CUDA language, it seemed not worth fixing.
|
||||||
|
|
||||||
IF (MSVC)
|
if(MSVC)
|
||||||
# we want to respect the standard, and we are bored of those **** .
|
# we want to respect the standard, and we are bored of those **** .
|
||||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE=1)
|
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE=1)
|
||||||
# skip unwanted includes from windows.h
|
# skip unwanted includes from windows.h
|
||||||
ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN)
|
ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN)
|
||||||
LIST(APPEND CUDA_NVCC_FLAGS "-Xcompiler /wd4819 -Xcompiler /wd4503 -Xcompiler /wd4190 -Xcompiler /wd4244 -Xcompiler /wd4251 -Xcompiler /wd4275 -Xcompiler /wd4522")
|
LIST(APPEND CUDA_NVCC_FLAGS "-Xcompiler /wd4819 -Xcompiler /wd4503 -Xcompiler /wd4190 -Xcompiler /wd4244 -Xcompiler /wd4251 -Xcompiler /wd4275 -Xcompiler /wd4522")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF (NOT MSVC)
|
if(NOT MSVC)
|
||||||
IF (CMAKE_VERSION VERSION_LESS "3.1")
|
if(CMAKE_VERSION VERSION_LESS "3.1")
|
||||||
SET(CMAKE_C_FLAGS "-std=c11 ${CMAKE_C_FLAGS}")
|
SET(CMAKE_C_FLAGS "-std=c11 ${CMAKE_C_FLAGS}")
|
||||||
ELSE ()
|
else()
|
||||||
SET(CMAKE_C_STANDARD 11)
|
SET(CMAKE_C_STANDARD 11)
|
||||||
ENDIF ()
|
endif()
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
LIST(APPEND CUDA_NVCC_FLAGS -Wno-deprecated-gpu-targets)
|
LIST(APPEND CUDA_NVCC_FLAGS -Wno-deprecated-gpu-targets)
|
||||||
LIST(APPEND CUDA_NVCC_FLAGS --expt-extended-lambda)
|
LIST(APPEND CUDA_NVCC_FLAGS --expt-extended-lambda)
|
||||||
|
|
||||||
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
SET(CMAKE_CXX_STANDARD 14)
|
SET(CMAKE_CXX_STANDARD 14)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
LIST(APPEND CUDA_NVCC_FLAGS ${TORCH_NVCC_FLAGS})
|
LIST(APPEND CUDA_NVCC_FLAGS ${TORCH_NVCC_FLAGS})
|
||||||
LIST(APPEND CUDA_NVCC_FLAGS ${NVCC_FLAGS_EXTRA})
|
LIST(APPEND CUDA_NVCC_FLAGS ${NVCC_FLAGS_EXTRA})
|
||||||
IF (CMAKE_POSITION_INDEPENDENT_CODE AND NOT MSVC)
|
if(CMAKE_POSITION_INDEPENDENT_CODE AND NOT MSVC)
|
||||||
LIST(APPEND CUDA_NVCC_FLAGS "-Xcompiler" "-fPIC")
|
LIST(APPEND CUDA_NVCC_FLAGS "-Xcompiler" "-fPIC")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF (CUDA_HAS_FP16 OR NOT ${CUDA_VERSION} LESS 7.5)
|
if(CUDA_HAS_FP16 OR NOT ${CUDA_VERSION} LESS 7.5)
|
||||||
MESSAGE(STATUS "Found CUDA with FP16 support, compiling with torch.cuda.HalfTensor")
|
MESSAGE(STATUS "Found CUDA with FP16 support, compiling with torch.cuda.HalfTensor")
|
||||||
LIST(APPEND CUDA_NVCC_FLAGS "-DCUDA_HAS_FP16=1 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__")
|
LIST(APPEND CUDA_NVCC_FLAGS "-DCUDA_HAS_FP16=1 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__")
|
||||||
add_compile_options(-DCUDA_HAS_FP16=1)
|
add_compile_options(-DCUDA_HAS_FP16=1)
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE(STATUS "Could not find CUDA with FP16 support, compiling without torch.CudaHalfTensor")
|
MESSAGE(STATUS "Could not find CUDA with FP16 support, compiling without torch.CudaHalfTensor")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
STRING(APPEND CMAKE_C_FLAGS_RELEASE " -DNDEBUG")
|
STRING(APPEND CMAKE_C_FLAGS_RELEASE " -DNDEBUG")
|
||||||
STRING(APPEND CMAKE_CXX_FLAGS_RELEASE " -DNDEBUG")
|
STRING(APPEND CMAKE_CXX_FLAGS_RELEASE " -DNDEBUG")
|
||||||
IF (NOT GENERATOR_IS_MULTI_CONFIG)
|
if(NOT GENERATOR_IS_MULTI_CONFIG)
|
||||||
IF (${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
|
||||||
MESSAGE(STATUS "Adding -DNDEBUG to compile flags")
|
MESSAGE(STATUS "Adding -DNDEBUG to compile flags")
|
||||||
STRING(APPEND CMAKE_C_FLAGS " -DNDEBUG")
|
STRING(APPEND CMAKE_C_FLAGS " -DNDEBUG")
|
||||||
STRING(APPEND CMAKE_CXX_FLAGS " -DNDEBUG")
|
STRING(APPEND CMAKE_CXX_FLAGS " -DNDEBUG")
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE(STATUS "Removing -DNDEBUG from compile flags")
|
MESSAGE(STATUS "Removing -DNDEBUG from compile flags")
|
||||||
STRING(REGEX REPLACE "[-/]DNDEBUG" "" CMAKE_C_FLAGS "" ${CMAKE_C_FLAGS})
|
STRING(REGEX REPLACE "[-/]DNDEBUG" "" CMAKE_C_FLAGS "" ${CMAKE_C_FLAGS})
|
||||||
STRING(REGEX REPLACE "[-/]DNDEBUG" "" CMAKE_CXX_FLAGS "" ${CMAKE_CXX_FLAGS})
|
STRING(REGEX REPLACE "[-/]DNDEBUG" "" CMAKE_CXX_FLAGS "" ${CMAKE_CXX_FLAGS})
|
||||||
ENDIF()
|
endif()
|
||||||
ENDIF()
|
endif()
|
||||||
STRING(REGEX REPLACE "[-/]DNDEBUG" "" CMAKE_C_FLAGS_DEBUG "" ${CMAKE_C_FLAGS_DEBUG})
|
STRING(REGEX REPLACE "[-/]DNDEBUG" "" CMAKE_C_FLAGS_DEBUG "" ${CMAKE_C_FLAGS_DEBUG})
|
||||||
STRING(REGEX REPLACE "[-/]DNDEBUG" "" CMAKE_CXX_FLAGS_DEBUG "" ${CMAKE_CXX_FLAGS_DEBUG})
|
STRING(REGEX REPLACE "[-/]DNDEBUG" "" CMAKE_CXX_FLAGS_DEBUG "" ${CMAKE_CXX_FLAGS_DEBUG})
|
||||||
|
|
||||||
SET(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE OFF)
|
SET(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE OFF)
|
||||||
|
|
||||||
FIND_PACKAGE(MAGMA)
|
FIND_PACKAGE(MAGMA)
|
||||||
IF (USE_CUDA AND MAGMA_FOUND)
|
if(USE_CUDA AND MAGMA_FOUND)
|
||||||
INCLUDE_DIRECTORIES(SYSTEM ${MAGMA_INCLUDE_DIR})
|
INCLUDE_DIRECTORIES(SYSTEM ${MAGMA_INCLUDE_DIR})
|
||||||
SET(CMAKE_REQUIRED_INCLUDES "${MAGMA_INCLUDE_DIR};${CUDA_INCLUDE_DIRS}")
|
SET(CMAKE_REQUIRED_INCLUDES "${MAGMA_INCLUDE_DIR};${CUDA_INCLUDE_DIRS}")
|
||||||
INCLUDE(CheckPrototypeDefinition)
|
INCLUDE(CheckPrototypeDefinition)
|
||||||
@ -1355,50 +1355,50 @@ if (NOT INTERN_BUILD_MOBILE)
|
|||||||
"0"
|
"0"
|
||||||
"magma.h"
|
"magma.h"
|
||||||
MAGMA_V2)
|
MAGMA_V2)
|
||||||
IF (MAGMA_V2)
|
if(MAGMA_V2)
|
||||||
add_definitions(-DMAGMA_V2)
|
add_definitions(-DMAGMA_V2)
|
||||||
ENDIF (MAGMA_V2)
|
endif(MAGMA_V2)
|
||||||
|
|
||||||
SET(USE_MAGMA 1)
|
SET(USE_MAGMA 1)
|
||||||
MESSAGE(STATUS "Compiling with MAGMA support")
|
MESSAGE(STATUS "Compiling with MAGMA support")
|
||||||
MESSAGE(STATUS "MAGMA INCLUDE DIRECTORIES: ${MAGMA_INCLUDE_DIR}")
|
MESSAGE(STATUS "MAGMA INCLUDE DIRECTORIES: ${MAGMA_INCLUDE_DIR}")
|
||||||
MESSAGE(STATUS "MAGMA LIBRARIES: ${MAGMA_LIBRARIES}")
|
MESSAGE(STATUS "MAGMA LIBRARIES: ${MAGMA_LIBRARIES}")
|
||||||
MESSAGE(STATUS "MAGMA V2 check: ${MAGMA_V2}")
|
MESSAGE(STATUS "MAGMA V2 check: ${MAGMA_V2}")
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE(STATUS "MAGMA not found. Compiling without MAGMA support")
|
MESSAGE(STATUS "MAGMA not found. Compiling without MAGMA support")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# ARM specific flags
|
# ARM specific flags
|
||||||
FIND_PACKAGE(ARM)
|
FIND_PACKAGE(ARM)
|
||||||
IF (ASIMD_FOUND)
|
if(ASIMD_FOUND)
|
||||||
MESSAGE(STATUS "asimd/Neon found with compiler flag : -D__NEON__")
|
MESSAGE(STATUS "asimd/Neon found with compiler flag : -D__NEON__")
|
||||||
add_compile_options(-D__NEON__)
|
add_compile_options(-D__NEON__)
|
||||||
ELSEIF (NEON_FOUND)
|
elseif(NEON_FOUND)
|
||||||
MESSAGE(STATUS "Neon found with compiler flag : -mfpu=neon -D__NEON__")
|
MESSAGE(STATUS "Neon found with compiler flag : -mfpu=neon -D__NEON__")
|
||||||
add_compile_options(-mfpu=neon -D__NEON__)
|
add_compile_options(-mfpu=neon -D__NEON__)
|
||||||
ENDIF ()
|
endif()
|
||||||
IF (CORTEXA8_FOUND)
|
if(CORTEXA8_FOUND)
|
||||||
MESSAGE(STATUS "Cortex-A8 Found with compiler flag : -mcpu=cortex-a8")
|
MESSAGE(STATUS "Cortex-A8 Found with compiler flag : -mcpu=cortex-a8")
|
||||||
add_compile_options(-mcpu=cortex-a8 -fprefetch-loop-arrays)
|
add_compile_options(-mcpu=cortex-a8 -fprefetch-loop-arrays)
|
||||||
ENDIF ()
|
endif()
|
||||||
IF (CORTEXA9_FOUND)
|
if(CORTEXA9_FOUND)
|
||||||
MESSAGE(STATUS "Cortex-A9 Found with compiler flag : -mcpu=cortex-a9")
|
MESSAGE(STATUS "Cortex-A9 Found with compiler flag : -mcpu=cortex-a9")
|
||||||
add_compile_options(-mcpu=cortex-a9)
|
add_compile_options(-mcpu=cortex-a9)
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
|
CHECK_INCLUDE_FILE(cpuid.h HAVE_CPUID_H)
|
||||||
# Check for a cpuid intrinsic
|
# Check for a cpuid intrinsic
|
||||||
IF (HAVE_CPUID_H)
|
if(HAVE_CPUID_H)
|
||||||
CHECK_C_SOURCE_COMPILES("#include <cpuid.h>
|
CHECK_C_SOURCE_COMPILES("#include <cpuid.h>
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
unsigned int eax, ebx, ecx, edx;
|
unsigned int eax, ebx, ecx, edx;
|
||||||
return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
|
return __get_cpuid(0, &eax, &ebx, &ecx, &edx);
|
||||||
}" HAVE_GCC_GET_CPUID)
|
}" HAVE_GCC_GET_CPUID)
|
||||||
ENDIF()
|
endif()
|
||||||
IF (HAVE_GCC_GET_CPUID)
|
if(HAVE_GCC_GET_CPUID)
|
||||||
add_compile_options(-DHAVE_GCC_GET_CPUID)
|
add_compile_options(-DHAVE_GCC_GET_CPUID)
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
CHECK_C_SOURCE_COMPILES("#include <stdint.h>
|
CHECK_C_SOURCE_COMPILES("#include <stdint.h>
|
||||||
static inline void cpuid(uint32_t *eax, uint32_t *ebx,
|
static inline void cpuid(uint32_t *eax, uint32_t *ebx,
|
||||||
@ -1414,124 +1414,124 @@ if (NOT INTERN_BUILD_MOBILE)
|
|||||||
return 0;
|
return 0;
|
||||||
}" NO_GCC_EBX_FPIC_BUG)
|
}" NO_GCC_EBX_FPIC_BUG)
|
||||||
|
|
||||||
IF (NOT NO_GCC_EBX_FPIC_BUG)
|
if(NOT NO_GCC_EBX_FPIC_BUG)
|
||||||
add_compile_options(-DUSE_GCC_GET_CPUID)
|
add_compile_options(-DUSE_GCC_GET_CPUID)
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
FIND_PACKAGE(AVX) # checks AVX and AVX2
|
FIND_PACKAGE(AVX) # checks AVX and AVX2
|
||||||
|
|
||||||
# we don't set -mavx and -mavx2 flags globally, but only for specific files
|
# we don't set -mavx and -mavx2 flags globally, but only for specific files
|
||||||
# however, we want to enable the AVX codepaths, so we still need to
|
# however, we want to enable the AVX codepaths, so we still need to
|
||||||
# add USE_AVX and USE_AVX2 macro defines
|
# add USE_AVX and USE_AVX2 macro defines
|
||||||
IF (C_AVX_FOUND)
|
if(C_AVX_FOUND)
|
||||||
MESSAGE(STATUS "AVX compiler support found")
|
MESSAGE(STATUS "AVX compiler support found")
|
||||||
add_compile_options(-DUSE_AVX)
|
add_compile_options(-DUSE_AVX)
|
||||||
ENDIF()
|
endif()
|
||||||
IF (C_AVX2_FOUND)
|
if(C_AVX2_FOUND)
|
||||||
MESSAGE(STATUS "AVX2 compiler support found")
|
MESSAGE(STATUS "AVX2 compiler support found")
|
||||||
add_compile_options(-DUSE_AVX2)
|
add_compile_options(-DUSE_AVX2)
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF (WIN32 AND NOT CYGWIN)
|
if(WIN32 AND NOT CYGWIN)
|
||||||
SET(BLAS_INSTALL_LIBRARIES "OFF"
|
SET(BLAS_INSTALL_LIBRARIES "OFF"
|
||||||
CACHE BOOL "Copy the required BLAS DLLs into the TH install dirs")
|
CACHE BOOL "Copy the required BLAS DLLs into the TH install dirs")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
FIND_PACKAGE(LAPACK)
|
FIND_PACKAGE(LAPACK)
|
||||||
IF (LAPACK_FOUND)
|
if(LAPACK_FOUND)
|
||||||
SET(USE_LAPACK 1)
|
SET(USE_LAPACK 1)
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
if (NOT USE_CUDA)
|
if(NOT USE_CUDA)
|
||||||
message("disabling CUDA because NOT USE_CUDA is set")
|
message("disabling CUDA because NOT USE_CUDA is set")
|
||||||
SET(AT_CUDA_ENABLED 0)
|
SET(AT_CUDA_ENABLED 0)
|
||||||
else()
|
else()
|
||||||
SET(AT_CUDA_ENABLED 1)
|
SET(AT_CUDA_ENABLED 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
IF (NOT USE_CUDNN)
|
if(NOT USE_CUDNN)
|
||||||
MESSAGE(STATUS "USE_CUDNN is set to 0. Compiling without cuDNN support")
|
MESSAGE(STATUS "USE_CUDNN is set to 0. Compiling without cuDNN support")
|
||||||
set(AT_CUDNN_ENABLED 0)
|
set(AT_CUDNN_ENABLED 0)
|
||||||
ELSEIF (NOT CUDNN_FOUND)
|
elseif(NOT CUDNN_FOUND)
|
||||||
MESSAGE(WARNING "CuDNN not found. Compiling without CuDNN support")
|
MESSAGE(WARNING "CuDNN not found. Compiling without CuDNN support")
|
||||||
set(AT_CUDNN_ENABLED 0)
|
set(AT_CUDNN_ENABLED 0)
|
||||||
ELSE()
|
else()
|
||||||
include_directories(SYSTEM ${CUDNN_INCLUDE_PATH})
|
include_directories(SYSTEM ${CUDNN_INCLUDE_PATH})
|
||||||
set(AT_CUDNN_ENABLED 1)
|
set(AT_CUDNN_ENABLED 1)
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF (NOT USE_ROCM)
|
if(NOT USE_ROCM)
|
||||||
message("disabling ROCM because NOT USE_ROCM is set")
|
message("disabling ROCM because NOT USE_ROCM is set")
|
||||||
MESSAGE(STATUS "MIOpen not found. Compiling without MIOpen support")
|
MESSAGE(STATUS "MIOpen not found. Compiling without MIOpen support")
|
||||||
set(AT_ROCM_ENABLED 0)
|
set(AT_ROCM_ENABLED 0)
|
||||||
ELSE()
|
else()
|
||||||
INCLUDE_DIRECTORIES(BEFORE ${MIOPEN_INCLUDE_DIRS})
|
INCLUDE_DIRECTORIES(BEFORE ${MIOPEN_INCLUDE_DIRS})
|
||||||
set(AT_ROCM_ENABLED 1)
|
set(AT_ROCM_ENABLED 1)
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
SET(AT_MKLDNN_ENABLED 0)
|
SET(AT_MKLDNN_ENABLED 0)
|
||||||
SET(CAFFE2_USE_MKLDNN OFF)
|
SET(CAFFE2_USE_MKLDNN OFF)
|
||||||
IF (USE_MKLDNN)
|
if(USE_MKLDNN)
|
||||||
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/public/mkldnn.cmake)
|
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/public/mkldnn.cmake)
|
||||||
IF(MKLDNN_FOUND)
|
if(MKLDNN_FOUND)
|
||||||
SET(AT_MKLDNN_ENABLED 1)
|
SET(AT_MKLDNN_ENABLED 1)
|
||||||
INCLUDE_DIRECTORIES(AFTER SYSTEM ${MKLDNN_INCLUDE_DIR})
|
INCLUDE_DIRECTORIES(AFTER SYSTEM ${MKLDNN_INCLUDE_DIR})
|
||||||
IF(BUILD_CAFFE2_OPS)
|
if(BUILD_CAFFE2_OPS)
|
||||||
SET(CAFFE2_USE_MKLDNN ON)
|
SET(CAFFE2_USE_MKLDNN ON)
|
||||||
LIST(APPEND Caffe2_PUBLIC_DEPENDENCY_LIBS caffe2::mkldnn)
|
LIST(APPEND Caffe2_PUBLIC_DEPENDENCY_LIBS caffe2::mkldnn)
|
||||||
ENDIF(BUILD_CAFFE2_OPS)
|
endif(BUILD_CAFFE2_OPS)
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE(WARNING "MKLDNN could not be found.")
|
MESSAGE(WARNING "MKLDNN could not be found.")
|
||||||
ENDIF()
|
endif()
|
||||||
ELSE()
|
else()
|
||||||
MESSAGE("disabling MKLDNN because USE_MKLDNN is not set")
|
MESSAGE("disabling MKLDNN because USE_MKLDNN is not set")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF(UNIX AND NOT APPLE)
|
if(UNIX AND NOT APPLE)
|
||||||
INCLUDE(CheckLibraryExists)
|
INCLUDE(CheckLibraryExists)
|
||||||
# https://github.com/libgit2/libgit2/issues/2128#issuecomment-35649830
|
# https://github.com/libgit2/libgit2/issues/2128#issuecomment-35649830
|
||||||
CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" NEED_LIBRT)
|
CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" NEED_LIBRT)
|
||||||
IF(NEED_LIBRT)
|
if(NEED_LIBRT)
|
||||||
list(APPEND Caffe2_DEPENDENCY_LIBS rt)
|
list(APPEND Caffe2_DEPENDENCY_LIBS rt)
|
||||||
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} rt)
|
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} rt)
|
||||||
ENDIF(NEED_LIBRT)
|
endif(NEED_LIBRT)
|
||||||
ENDIF(UNIX AND NOT APPLE)
|
endif(UNIX AND NOT APPLE)
|
||||||
|
|
||||||
IF(UNIX)
|
if(UNIX)
|
||||||
SET(CMAKE_EXTRA_INCLUDE_FILES "sys/mman.h")
|
SET(CMAKE_EXTRA_INCLUDE_FILES "sys/mman.h")
|
||||||
CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP)
|
CHECK_FUNCTION_EXISTS(mmap HAVE_MMAP)
|
||||||
IF(HAVE_MMAP)
|
if(HAVE_MMAP)
|
||||||
ADD_DEFINITIONS(-DHAVE_MMAP=1)
|
ADD_DEFINITIONS(-DHAVE_MMAP=1)
|
||||||
ENDIF(HAVE_MMAP)
|
endif(HAVE_MMAP)
|
||||||
# done for lseek: https://www.gnu.org/software/libc/manual/html_node/File-Position-Primitive.html
|
# done for lseek: https://www.gnu.org/software/libc/manual/html_node/File-Position-Primitive.html
|
||||||
ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64)
|
ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64)
|
||||||
CHECK_FUNCTION_EXISTS(shm_open HAVE_SHM_OPEN)
|
CHECK_FUNCTION_EXISTS(shm_open HAVE_SHM_OPEN)
|
||||||
IF(HAVE_SHM_OPEN)
|
if(HAVE_SHM_OPEN)
|
||||||
ADD_DEFINITIONS(-DHAVE_SHM_OPEN=1)
|
ADD_DEFINITIONS(-DHAVE_SHM_OPEN=1)
|
||||||
ENDIF(HAVE_SHM_OPEN)
|
endif(HAVE_SHM_OPEN)
|
||||||
CHECK_FUNCTION_EXISTS(shm_unlink HAVE_SHM_UNLINK)
|
CHECK_FUNCTION_EXISTS(shm_unlink HAVE_SHM_UNLINK)
|
||||||
IF(HAVE_SHM_UNLINK)
|
if(HAVE_SHM_UNLINK)
|
||||||
ADD_DEFINITIONS(-DHAVE_SHM_UNLINK=1)
|
ADD_DEFINITIONS(-DHAVE_SHM_UNLINK=1)
|
||||||
ENDIF(HAVE_SHM_UNLINK)
|
endif(HAVE_SHM_UNLINK)
|
||||||
CHECK_FUNCTION_EXISTS(malloc_usable_size HAVE_MALLOC_USABLE_SIZE)
|
CHECK_FUNCTION_EXISTS(malloc_usable_size HAVE_MALLOC_USABLE_SIZE)
|
||||||
IF(HAVE_MALLOC_USABLE_SIZE)
|
if(HAVE_MALLOC_USABLE_SIZE)
|
||||||
ADD_DEFINITIONS(-DHAVE_MALLOC_USABLE_SIZE=1)
|
ADD_DEFINITIONS(-DHAVE_MALLOC_USABLE_SIZE=1)
|
||||||
ENDIF(HAVE_MALLOC_USABLE_SIZE)
|
endif(HAVE_MALLOC_USABLE_SIZE)
|
||||||
ENDIF(UNIX)
|
endif(UNIX)
|
||||||
|
|
||||||
ADD_DEFINITIONS(-DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS)
|
ADD_DEFINITIONS(-DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS)
|
||||||
|
|
||||||
# Is __thread supported?
|
# Is __thread supported?
|
||||||
IF(NOT MSVC)
|
if(NOT MSVC)
|
||||||
CHECK_C_SOURCE_COMPILES("static __thread int x = 1; int main() { return x; }" C_HAS_THREAD)
|
CHECK_C_SOURCE_COMPILES("static __thread int x = 1; int main() { return x; }" C_HAS_THREAD)
|
||||||
ELSE(NOT MSVC)
|
else(NOT MSVC)
|
||||||
CHECK_C_SOURCE_COMPILES("static __declspec( thread ) int x = 1; int main() { return x; }" C_HAS_THREAD)
|
CHECK_C_SOURCE_COMPILES("static __declspec( thread ) int x = 1; int main() { return x; }" C_HAS_THREAD)
|
||||||
ENDIF(NOT MSVC)
|
endif(NOT MSVC)
|
||||||
IF(NOT C_HAS_THREAD)
|
if(NOT C_HAS_THREAD)
|
||||||
MESSAGE(STATUS "Warning: __thread is not supported, generating thread-unsafe code")
|
MESSAGE(STATUS "Warning: __thread is not supported, generating thread-unsafe code")
|
||||||
ELSE(NOT C_HAS_THREAD)
|
else(NOT C_HAS_THREAD)
|
||||||
add_compile_options(-DTH_HAVE_THREAD)
|
add_compile_options(-DTH_HAVE_THREAD)
|
||||||
ENDIF(NOT C_HAS_THREAD)
|
endif(NOT C_HAS_THREAD)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#
|
#
|
||||||
|
6
cmake/External/nccl.cmake
vendored
6
cmake/External/nccl.cmake
vendored
@ -1,10 +1,10 @@
|
|||||||
if (NOT __NCCL_INCLUDED)
|
if(NOT __NCCL_INCLUDED)
|
||||||
set(__NCCL_INCLUDED TRUE)
|
set(__NCCL_INCLUDED TRUE)
|
||||||
|
|
||||||
if (USE_SYSTEM_NCCL)
|
if(USE_SYSTEM_NCCL)
|
||||||
# NCCL_ROOT, NCCL_LIB_DIR, NCCL_INCLUDE_DIR will be accounted in the following line.
|
# NCCL_ROOT, NCCL_LIB_DIR, NCCL_INCLUDE_DIR will be accounted in the following line.
|
||||||
find_package(NCCL REQUIRED)
|
find_package(NCCL REQUIRED)
|
||||||
if (NCCL_FOUND)
|
if(NCCL_FOUND)
|
||||||
add_library(__caffe2_nccl INTERFACE)
|
add_library(__caffe2_nccl INTERFACE)
|
||||||
target_link_libraries(__caffe2_nccl INTERFACE ${NCCL_LIBRARIES})
|
target_link_libraries(__caffe2_nccl INTERFACE ${NCCL_LIBRARIES})
|
||||||
target_include_directories(__caffe2_nccl INTERFACE ${NCCL_INCLUDE_DIRS})
|
target_include_directories(__caffe2_nccl INTERFACE ${NCCL_INCLUDE_DIRS})
|
||||||
|
10
cmake/External/nnpack.cmake
vendored
10
cmake/External/nnpack.cmake
vendored
@ -1,9 +1,9 @@
|
|||||||
if (__NNPACK_INCLUDED)
|
if(__NNPACK_INCLUDED)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
set(__NNPACK_INCLUDED TRUE)
|
set(__NNPACK_INCLUDED TRUE)
|
||||||
|
|
||||||
if (NOT USE_NNPACK)
|
if(NOT USE_NNPACK)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ endif()
|
|||||||
# (1) MSVC - unsupported
|
# (1) MSVC - unsupported
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
if (MSVC)
|
if(MSVC)
|
||||||
message(WARNING "NNPACK not supported on MSVC yet. Turn this warning off by USE_NNPACK=OFF.")
|
message(WARNING "NNPACK not supported on MSVC yet. Turn this warning off by USE_NNPACK=OFF.")
|
||||||
set(USE_NNPACK OFF)
|
set(USE_NNPACK OFF)
|
||||||
return()
|
return()
|
||||||
@ -40,7 +40,7 @@ endif()
|
|||||||
# (3) Android, iOS, Linux, macOS - supported
|
# (3) Android, iOS, Linux, macOS - supported
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
if (ANDROID OR IOS OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
if(ANDROID OR IOS OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||||
message(STATUS "Brace yourself, we are building NNPACK")
|
message(STATUS "Brace yourself, we are building NNPACK")
|
||||||
set(CAFFE2_THIRD_PARTY_ROOT ${PROJECT_SOURCE_DIR}/third_party)
|
set(CAFFE2_THIRD_PARTY_ROOT ${PROJECT_SOURCE_DIR}/third_party)
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ if (ANDROID OR IOS OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NA
|
|||||||
set(PYTHON_SIX_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/python-six" CACHE STRING "six (Python package) source directory")
|
set(PYTHON_SIX_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/python-six" CACHE STRING "six (Python package) source directory")
|
||||||
set(PYTHON_ENUM_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/python-enum" CACHE STRING "enum34 (Python package) source directory")
|
set(PYTHON_ENUM_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/python-enum" CACHE STRING "enum34 (Python package) source directory")
|
||||||
set(PYTHON_PEACHPY_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/python-peachpy" CACHE STRING "PeachPy (Python package) source directory")
|
set(PYTHON_PEACHPY_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/python-peachpy" CACHE STRING "PeachPy (Python package) source directory")
|
||||||
if (NOT DEFINED CPUINFO_SOURCE_DIR)
|
if(NOT DEFINED CPUINFO_SOURCE_DIR)
|
||||||
set(CPUINFO_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/cpuinfo" CACHE STRING "cpuinfo source directory")
|
set(CPUINFO_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/cpuinfo" CACHE STRING "cpuinfo source directory")
|
||||||
endif()
|
endif()
|
||||||
set(NNPACK_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/NNPACK" CACHE STRING "NNPACK source directory")
|
set(NNPACK_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/NNPACK" CACHE STRING "NNPACK source directory")
|
||||||
|
6
cmake/External/rccl.cmake
vendored
6
cmake/External/rccl.cmake
vendored
@ -1,10 +1,10 @@
|
|||||||
if (NOT __NCCL_INCLUDED)
|
if(NOT __NCCL_INCLUDED)
|
||||||
set(__NCCL_INCLUDED TRUE)
|
set(__NCCL_INCLUDED TRUE)
|
||||||
|
|
||||||
if (USE_SYSTEM_NCCL)
|
if(USE_SYSTEM_NCCL)
|
||||||
# NCCL_ROOT, NCCL_LIB_DIR, NCCL_INCLUDE_DIR will be accounted in the following line.
|
# NCCL_ROOT, NCCL_LIB_DIR, NCCL_INCLUDE_DIR will be accounted in the following line.
|
||||||
find_package(RCCL REQUIRED)
|
find_package(RCCL REQUIRED)
|
||||||
if (RCCL_FOUND)
|
if(RCCL_FOUND)
|
||||||
message (STATUS "RCCL Found!")
|
message (STATUS "RCCL Found!")
|
||||||
add_library(__caffe2_nccl INTERFACE)
|
add_library(__caffe2_nccl INTERFACE)
|
||||||
target_link_libraries(__caffe2_nccl INTERFACE ${PYTORCH_RCCL_LIBRARIES})
|
target_link_libraries(__caffe2_nccl INTERFACE ${PYTORCH_RCCL_LIBRARIES})
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
if (UNIX)
|
if(UNIX)
|
||||||
# prevent Unknown CMake command "check_function_exists".
|
# prevent Unknown CMake command "check_function_exists".
|
||||||
include(CheckFunctionExists)
|
include(CheckFunctionExists)
|
||||||
endif()
|
endif()
|
||||||
@ -37,7 +37,7 @@ if(EXISTS "/etc/os-release")
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT INTERN_BUILD_MOBILE)
|
if(NOT INTERN_BUILD_MOBILE)
|
||||||
# ---[ Check that our programs run. This is different from the native CMake
|
# ---[ Check that our programs run. This is different from the native CMake
|
||||||
# compiler check, which just tests if the program compiles and links. This is
|
# compiler check, which just tests if the program compiles and links. This is
|
||||||
# important because with ASAN you might need to help the compiled library find
|
# important because with ASAN you might need to help the compiled library find
|
||||||
@ -46,7 +46,7 @@ if (NOT INTERN_BUILD_MOBILE)
|
|||||||
CHECK_C_SOURCE_RUNS("
|
CHECK_C_SOURCE_RUNS("
|
||||||
int main() { return 0; }
|
int main() { return 0; }
|
||||||
" COMPILER_WORKS)
|
" COMPILER_WORKS)
|
||||||
if (NOT COMPILER_WORKS)
|
if(NOT COMPILER_WORKS)
|
||||||
# Force cmake to retest next time around
|
# Force cmake to retest next time around
|
||||||
unset(COMPILER_WORKS CACHE)
|
unset(COMPILER_WORKS CACHE)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
@ -59,7 +59,7 @@ if (NOT INTERN_BUILD_MOBILE)
|
|||||||
cmake_pop_check_state()
|
cmake_pop_check_state()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT INTERN_BUILD_MOBILE)
|
if(NOT INTERN_BUILD_MOBILE)
|
||||||
# ---[ Check if certain std functions are supported. Sometimes
|
# ---[ Check if certain std functions are supported. Sometimes
|
||||||
# _GLIBCXX_USE_C99 macro is not defined and some functions are missing.
|
# _GLIBCXX_USE_C99 macro is not defined and some functions are missing.
|
||||||
cmake_push_check_state(RESET)
|
cmake_push_check_state(RESET)
|
||||||
@ -75,7 +75,7 @@ if (NOT INTERN_BUILD_MOBILE)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}" SUPPORT_GLIBCXX_USE_C99)
|
}" SUPPORT_GLIBCXX_USE_C99)
|
||||||
if (NOT SUPPORT_GLIBCXX_USE_C99)
|
if(NOT SUPPORT_GLIBCXX_USE_C99)
|
||||||
# Force cmake to retest next time around
|
# Force cmake to retest next time around
|
||||||
unset(SUPPORT_GLIBCXX_USE_C99 CACHE)
|
unset(SUPPORT_GLIBCXX_USE_C99 CACHE)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
@ -103,7 +103,7 @@ CHECK_CXX_SOURCE_COMPILES(
|
|||||||
}
|
}
|
||||||
}" CAFFE2_EXCEPTION_PTR_SUPPORTED)
|
}" CAFFE2_EXCEPTION_PTR_SUPPORTED)
|
||||||
|
|
||||||
if (CAFFE2_EXCEPTION_PTR_SUPPORTED)
|
if(CAFFE2_EXCEPTION_PTR_SUPPORTED)
|
||||||
message(STATUS "std::exception_ptr is supported.")
|
message(STATUS "std::exception_ptr is supported.")
|
||||||
set(CAFFE2_USE_EXCEPTION_PTR 1)
|
set(CAFFE2_USE_EXCEPTION_PTR 1)
|
||||||
else()
|
else()
|
||||||
@ -132,9 +132,9 @@ endif()
|
|||||||
cmake_pop_check_state()
|
cmake_pop_check_state()
|
||||||
|
|
||||||
# ---[ Check if the compiler has AVX/AVX2 support. We only check AVX2.
|
# ---[ Check if the compiler has AVX/AVX2 support. We only check AVX2.
|
||||||
if (NOT INTERN_BUILD_MOBILE)
|
if(NOT INTERN_BUILD_MOBILE)
|
||||||
cmake_push_check_state(RESET)
|
cmake_push_check_state(RESET)
|
||||||
if (MSVC)
|
if(MSVC)
|
||||||
set(CMAKE_REQUIRED_FLAGS "/arch:AVX2")
|
set(CMAKE_REQUIRED_FLAGS "/arch:AVX2")
|
||||||
else()
|
else()
|
||||||
set(CMAKE_REQUIRED_FLAGS "-mavx2")
|
set(CMAKE_REQUIRED_FLAGS "-mavx2")
|
||||||
@ -150,7 +150,7 @@ if (NOT INTERN_BUILD_MOBILE)
|
|||||||
_mm256_extract_epi64(x, 0); // we rely on this in our AVX2 code
|
_mm256_extract_epi64(x, 0); // we rely on this in our AVX2 code
|
||||||
return 0;
|
return 0;
|
||||||
}" CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS)
|
}" CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS)
|
||||||
if (CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS)
|
if(CAFFE2_COMPILER_SUPPORTS_AVX2_EXTENSIONS)
|
||||||
message(STATUS "Current compiler supports avx2 extension. Will build perfkernels.")
|
message(STATUS "Current compiler supports avx2 extension. Will build perfkernels.")
|
||||||
# Also see CMakeLists.txt under caffe2/perfkernels.
|
# Also see CMakeLists.txt under caffe2/perfkernels.
|
||||||
set(CAFFE2_PERF_WITH_AVX 1)
|
set(CAFFE2_PERF_WITH_AVX 1)
|
||||||
@ -160,7 +160,7 @@ if (NOT INTERN_BUILD_MOBILE)
|
|||||||
endif()
|
endif()
|
||||||
# ---[ Check if the compiler has AVX512 support.
|
# ---[ Check if the compiler has AVX512 support.
|
||||||
cmake_push_check_state(RESET)
|
cmake_push_check_state(RESET)
|
||||||
if (MSVC)
|
if(MSVC)
|
||||||
# We could've used MSVC's hidden option /arch:AVX512 that defines __AVX512F__,
|
# We could've used MSVC's hidden option /arch:AVX512 that defines __AVX512F__,
|
||||||
# __AVX512DQ__, and __AVX512VL__, and /arch:AVX512F that defines __AVX512F__.
|
# __AVX512DQ__, and __AVX512VL__, and /arch:AVX512F that defines __AVX512F__.
|
||||||
# But, we chose not to do that not to rely on hidden options.
|
# But, we chose not to do that not to rely on hidden options.
|
||||||
@ -194,7 +194,7 @@ CHECK_CXX_SOURCE_COMPILES(
|
|||||||
__mmask16 m = _mm512_cmp_epi32_mask(a, a, _MM_CMPINT_EQ);
|
__mmask16 m = _mm512_cmp_epi32_mask(a, a, _MM_CMPINT_EQ);
|
||||||
__m512i r = _mm512_andnot_si512(a, a);
|
__m512i r = _mm512_andnot_si512(a, a);
|
||||||
}" CAFFE2_COMPILER_SUPPORTS_AVX512_EXTENSIONS)
|
}" CAFFE2_COMPILER_SUPPORTS_AVX512_EXTENSIONS)
|
||||||
if (CAFFE2_COMPILER_SUPPORTS_AVX512_EXTENSIONS)
|
if(CAFFE2_COMPILER_SUPPORTS_AVX512_EXTENSIONS)
|
||||||
message(STATUS "Current compiler supports avx512f extension. Will build fbgemm.")
|
message(STATUS "Current compiler supports avx512f extension. Will build fbgemm.")
|
||||||
# Also see CMakeLists.txt under caffe2/perfkernels.
|
# Also see CMakeLists.txt under caffe2/perfkernels.
|
||||||
set(CAFFE2_PERF_WITH_AVX512 1)
|
set(CAFFE2_PERF_WITH_AVX512 1)
|
||||||
@ -204,7 +204,7 @@ cmake_pop_check_state()
|
|||||||
# ---[ Checks if compiler supports -fvisibility=hidden
|
# ---[ Checks if compiler supports -fvisibility=hidden
|
||||||
check_cxx_compiler_flag("-fvisibility=hidden" COMPILER_SUPPORTS_HIDDEN_VISIBILITY)
|
check_cxx_compiler_flag("-fvisibility=hidden" COMPILER_SUPPORTS_HIDDEN_VISIBILITY)
|
||||||
check_cxx_compiler_flag("-fvisibility-inlines-hidden" COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY)
|
check_cxx_compiler_flag("-fvisibility-inlines-hidden" COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY)
|
||||||
if (${COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY})
|
if(${COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY})
|
||||||
set(CAFFE2_VISIBILITY_FLAG "-fvisibility-inlines-hidden")
|
set(CAFFE2_VISIBILITY_FLAG "-fvisibility-inlines-hidden")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CAFFE2_VISIBILITY_FLAG}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CAFFE2_VISIBILITY_FLAG}")
|
||||||
endif()
|
endif()
|
||||||
@ -214,7 +214,7 @@ endif()
|
|||||||
# -table. We need this to get symbols when generating backtrace at
|
# -table. We need this to get symbols when generating backtrace at
|
||||||
# -runtime.
|
# -runtime.
|
||||||
check_cxx_compiler_flag("-rdynamic" COMPILER_SUPPORTS_RDYNAMIC)
|
check_cxx_compiler_flag("-rdynamic" COMPILER_SUPPORTS_RDYNAMIC)
|
||||||
if (${COMPILER_SUPPORTS_RDYNAMIC})
|
if(${COMPILER_SUPPORTS_RDYNAMIC})
|
||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic")
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rdynamic")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
|
||||||
endif()
|
endif()
|
||||||
@ -225,7 +225,7 @@ endif()
|
|||||||
# a third party library (like Protobuf), mention it in the comment as
|
# a third party library (like Protobuf), mention it in the comment as
|
||||||
# "THIRD_PARTY_NAME related"
|
# "THIRD_PARTY_NAME related"
|
||||||
# From https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/
|
# From https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/
|
||||||
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
##########################################
|
##########################################
|
||||||
# Protobuf related. Cannot remove.
|
# Protobuf related. Cannot remove.
|
||||||
@ -306,7 +306,7 @@ endif()
|
|||||||
# Also, we will turn off deprecated-declarations
|
# Also, we will turn off deprecated-declarations
|
||||||
# due to protobuf.
|
# due to protobuf.
|
||||||
|
|
||||||
if (IOS)
|
if(IOS)
|
||||||
add_definitions("-mfpu=neon-fp16")
|
add_definitions("-mfpu=neon-fp16")
|
||||||
add_definitions("-Wno-deprecated-declarations")
|
add_definitions("-Wno-deprecated-declarations")
|
||||||
endif()
|
endif()
|
||||||
@ -314,7 +314,7 @@ endif()
|
|||||||
# ---[ If we use asan, turn on the flags.
|
# ---[ If we use asan, turn on the flags.
|
||||||
# TODO: This only works with new style gcc and clang (not the old -faddress-sanitizer).
|
# TODO: This only works with new style gcc and clang (not the old -faddress-sanitizer).
|
||||||
# Change if necessary on old platforms.
|
# Change if necessary on old platforms.
|
||||||
if (USE_ASAN)
|
if(USE_ASAN)
|
||||||
set(CAFFE2_ASAN_FLAG "-fsanitize=address -fPIE -pie")
|
set(CAFFE2_ASAN_FLAG "-fsanitize=address -fPIE -pie")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CAFFE2_ASAN_FLAG}")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CAFFE2_ASAN_FLAG}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CAFFE2_ASAN_FLAG}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CAFFE2_ASAN_FLAG}")
|
||||||
@ -323,7 +323,7 @@ if (USE_ASAN)
|
|||||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CAFFE2_ASAN_FLAG}")
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CAFFE2_ASAN_FLAG}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (USE_TSAN)
|
if(USE_TSAN)
|
||||||
set(CAFFE2_TSAN_FLAG "-fsanitize=thread -fPIE -pie")
|
set(CAFFE2_TSAN_FLAG "-fsanitize=thread -fPIE -pie")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CAFFE2_TSAN_FLAG}")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CAFFE2_TSAN_FLAG}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CAFFE2_TSAN_FLAG}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CAFFE2_TSAN_FLAG}")
|
||||||
@ -335,9 +335,9 @@ endif()
|
|||||||
# ---[ Create CAFFE2_BUILD_SHARED_LIBS for macros.h.in usage.
|
# ---[ Create CAFFE2_BUILD_SHARED_LIBS for macros.h.in usage.
|
||||||
set(CAFFE2_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
|
set(CAFFE2_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
|
||||||
|
|
||||||
if (USE_NATIVE_ARCH)
|
if(USE_NATIVE_ARCH)
|
||||||
check_cxx_compiler_flag("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
|
check_cxx_compiler_flag("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
|
||||||
if (COMPILER_SUPPORTS_MARCH_NATIVE)
|
if(COMPILER_SUPPORTS_MARCH_NATIVE)
|
||||||
add_definitions("-march=native")
|
add_definitions("-march=native")
|
||||||
else()
|
else()
|
||||||
message(
|
message(
|
||||||
|
@ -5,12 +5,12 @@ macro(custom_protobuf_find)
|
|||||||
option(protobuf_BUILD_TESTS "" OFF)
|
option(protobuf_BUILD_TESTS "" OFF)
|
||||||
option(protobuf_BUILD_EXAMPLES "" OFF)
|
option(protobuf_BUILD_EXAMPLES "" OFF)
|
||||||
option(protobuf_WITH_ZLIB "" OFF)
|
option(protobuf_WITH_ZLIB "" OFF)
|
||||||
if (APPLE)
|
if(APPLE)
|
||||||
# Protobuf generated files triggers a deprecated atomic operation warning
|
# Protobuf generated files triggers a deprecated atomic operation warning
|
||||||
# so we turn it off here.
|
# so we turn it off here.
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
|
||||||
endif()
|
endif()
|
||||||
if (${CAFFE2_LINK_LOCAL_PROTOBUF})
|
if(${CAFFE2_LINK_LOCAL_PROTOBUF})
|
||||||
# If we are going to link protobuf locally, we will need to turn off
|
# If we are going to link protobuf locally, we will need to turn off
|
||||||
# shared libs build for protobuf.
|
# shared libs build for protobuf.
|
||||||
option(protobuf_BUILD_SHARED_LIBS "" OFF)
|
option(protobuf_BUILD_SHARED_LIBS "" OFF)
|
||||||
@ -22,15 +22,15 @@ macro(custom_protobuf_find)
|
|||||||
# We will make sure that protobuf and caffe2 uses the same msvc runtime.
|
# We will make sure that protobuf and caffe2 uses the same msvc runtime.
|
||||||
option(protobuf_MSVC_STATIC_RUNTIME "" ${CAFFE2_USE_MSVC_STATIC_RUNTIME})
|
option(protobuf_MSVC_STATIC_RUNTIME "" ${CAFFE2_USE_MSVC_STATIC_RUNTIME})
|
||||||
|
|
||||||
if (${CAFFE2_LINK_LOCAL_PROTOBUF})
|
if(${CAFFE2_LINK_LOCAL_PROTOBUF})
|
||||||
set(__caffe2_CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ${CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS})
|
set(__caffe2_CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ${CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS})
|
||||||
set(__caffe2_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
set(__caffe2_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
|
||||||
set(BUILD_SHARED_LIBS OFF)
|
set(BUILD_SHARED_LIBS OFF)
|
||||||
if (${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
|
if(${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
|
||||||
endif()
|
endif()
|
||||||
if (${COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY})
|
if(${COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY})
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@ -38,7 +38,7 @@ macro(custom_protobuf_find)
|
|||||||
set(__caffe2_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE})
|
set(__caffe2_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE})
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
if (MSVC)
|
if(MSVC)
|
||||||
if(MSVC_Z7_OVERRIDE)
|
if(MSVC_Z7_OVERRIDE)
|
||||||
foreach(flag_var
|
foreach(flag_var
|
||||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||||
@ -56,7 +56,7 @@ macro(custom_protobuf_find)
|
|||||||
|
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE ${__caffe2_CMAKE_POSITION_INDEPENDENT_CODE})
|
set(CMAKE_POSITION_INDEPENDENT_CODE ${__caffe2_CMAKE_POSITION_INDEPENDENT_CODE})
|
||||||
|
|
||||||
if (${CAFFE2_LINK_LOCAL_PROTOBUF})
|
if(${CAFFE2_LINK_LOCAL_PROTOBUF})
|
||||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ${__caffe2_CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS})
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ${__caffe2_CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS})
|
||||||
set(BUILD_SHARED_LIBS ON)
|
set(BUILD_SHARED_LIBS ON)
|
||||||
set(CMAKE_CXX_FLAGS ${__caffe2_CMAKE_CXX_FLAGS})
|
set(CMAKE_CXX_FLAGS ${__caffe2_CMAKE_CXX_FLAGS})
|
||||||
@ -64,13 +64,13 @@ macro(custom_protobuf_find)
|
|||||||
|
|
||||||
# Protobuf "namespaced" target is only added post protobuf 3.5.1. As a
|
# Protobuf "namespaced" target is only added post protobuf 3.5.1. As a
|
||||||
# result, for older versions, we will manually add alias.
|
# result, for older versions, we will manually add alias.
|
||||||
if (NOT TARGET protobuf::libprotobuf)
|
if(NOT TARGET protobuf::libprotobuf)
|
||||||
add_library(protobuf::libprotobuf ALIAS libprotobuf)
|
add_library(protobuf::libprotobuf ALIAS libprotobuf)
|
||||||
add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite)
|
add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite)
|
||||||
# There is link error when cross compiling protoc on mobile:
|
# There is link error when cross compiling protoc on mobile:
|
||||||
# https://github.com/protocolbuffers/protobuf/issues/2719
|
# https://github.com/protocolbuffers/protobuf/issues/2719
|
||||||
# And protoc is very unlikely needed for mobile builds.
|
# And protoc is very unlikely needed for mobile builds.
|
||||||
if (NOT (ANDROID OR IOS))
|
if(NOT (ANDROID OR IOS))
|
||||||
add_executable(protobuf::protoc ALIAS protoc)
|
add_executable(protobuf::protoc ALIAS protoc)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@ -79,8 +79,8 @@ endmacro()
|
|||||||
# Main entry for protobuf. If we are building on Android, iOS or we have hard
|
# Main entry for protobuf. If we are building on Android, iOS or we have hard
|
||||||
# coded BUILD_CUSTOM_PROTOBUF, we will hard code the use of custom protobuf
|
# coded BUILD_CUSTOM_PROTOBUF, we will hard code the use of custom protobuf
|
||||||
# in the submodule.
|
# in the submodule.
|
||||||
if (ANDROID OR IOS)
|
if(ANDROID OR IOS)
|
||||||
if (NOT ${BUILD_CUSTOM_PROTOBUF})
|
if(NOT ${BUILD_CUSTOM_PROTOBUF})
|
||||||
message(WARNING
|
message(WARNING
|
||||||
"For Android and iOS cross compilation, I am automatically using "
|
"For Android and iOS cross compilation, I am automatically using "
|
||||||
"custom protobuf under third party. Note that this behavior may "
|
"custom protobuf under third party. Note that this behavior may "
|
||||||
@ -94,14 +94,14 @@ if (ANDROID OR IOS)
|
|||||||
set(protobuf_BUILD_PROTOC_BINARIES OFF CACHE BOOL "" FORCE)
|
set(protobuf_BUILD_PROTOC_BINARIES OFF CACHE BOOL "" FORCE)
|
||||||
custom_protobuf_find()
|
custom_protobuf_find()
|
||||||
set(protobuf_BUILD_PROTOC_BINARIES ${__caffe2_protobuf_BUILD_PROTOC_BINARIES} CACHE BOOL "" FORCE)
|
set(protobuf_BUILD_PROTOC_BINARIES ${__caffe2_protobuf_BUILD_PROTOC_BINARIES} CACHE BOOL "" FORCE)
|
||||||
elseif (BUILD_CUSTOM_PROTOBUF)
|
elseif(BUILD_CUSTOM_PROTOBUF)
|
||||||
message(STATUS "Building using own protobuf under third_party per request.")
|
message(STATUS "Building using own protobuf under third_party per request.")
|
||||||
custom_protobuf_find()
|
custom_protobuf_find()
|
||||||
else()
|
else()
|
||||||
include(cmake/public/protobuf.cmake)
|
include(cmake/public/protobuf.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if ((NOT TARGET protobuf::libprotobuf) AND (NOT TARGET protobuf::libprotobuf-lite))
|
if((NOT TARGET protobuf::libprotobuf) AND (NOT TARGET protobuf::libprotobuf-lite))
|
||||||
message(WARNING
|
message(WARNING
|
||||||
"Protobuf cannot be found. Caffe2 will automatically switch to use "
|
"Protobuf cannot be found. Caffe2 will automatically switch to use "
|
||||||
"own protobuf under third_party. Note that this behavior may change in "
|
"own protobuf under third_party. Note that this behavior may change in "
|
||||||
@ -124,7 +124,7 @@ include_directories(BEFORE SYSTEM ${__tmp})
|
|||||||
# If Protobuf_VERSION is known (true in most cases, false if we are building
|
# If Protobuf_VERSION is known (true in most cases, false if we are building
|
||||||
# local protobuf), then we will add a protobuf version check in
|
# local protobuf), then we will add a protobuf version check in
|
||||||
# Caffe2Config.cmake.in.
|
# Caffe2Config.cmake.in.
|
||||||
if (DEFINED ${Protobuf_VERSION})
|
if(DEFINED ${Protobuf_VERSION})
|
||||||
set(CAFFE2_KNOWN_PROTOBUF_VERSION TRUE)
|
set(CAFFE2_KNOWN_PROTOBUF_VERSION TRUE)
|
||||||
else()
|
else()
|
||||||
set(CAFFE2_KNOWN_PROTOBUF_VERSION FALSE)
|
set(CAFFE2_KNOWN_PROTOBUF_VERSION FALSE)
|
||||||
@ -176,7 +176,7 @@ function(caffe2_protobuf_generate_cpp_py srcs_var hdrs_var python_var)
|
|||||||
# directory and are building it as part of the Caffe2 build. If
|
# directory and are building it as part of the Caffe2 build. If
|
||||||
# points to an existing path, it is a no-op.
|
# points to an existing path, it is a no-op.
|
||||||
|
|
||||||
if (${CAFFE2_LINK_LOCAL_PROTOBUF})
|
if(${CAFFE2_LINK_LOCAL_PROTOBUF})
|
||||||
# We need to rewrite the pb.h files to route GetEmptyStringAlreadyInited
|
# We need to rewrite the pb.h files to route GetEmptyStringAlreadyInited
|
||||||
# through our wrapper in proto_utils so the memory location test
|
# through our wrapper in proto_utils so the memory location test
|
||||||
# is correct.
|
# is correct.
|
||||||
|
@ -46,7 +46,7 @@ foreach(ns ${NAMESPACES})
|
|||||||
set(search "namespace ${ns} {")
|
set(search "namespace ${ns} {")
|
||||||
string(LENGTH "${search}" search_len)
|
string(LENGTH "${search}" search_len)
|
||||||
string(FIND "${content}" "${search}" pos)
|
string(FIND "${content}" "${search}" pos)
|
||||||
if (${pos} GREATER -1)
|
if(${pos} GREATER -1)
|
||||||
math(EXPR pos "${pos}+${search_len}")
|
math(EXPR pos "${pos}+${search_len}")
|
||||||
string(SUBSTRING "${content}" 0 ${pos} content_pre)
|
string(SUBSTRING "${content}" 0 ${pos} content_pre)
|
||||||
string(SUBSTRING "${content}" ${pos} -1 content_post)
|
string(SUBSTRING "${content}" ${pos} -1 content_post)
|
||||||
@ -63,7 +63,7 @@ endforeach()
|
|||||||
# a link error that claims that the vftable is not found. Luckily, we
|
# a link error that claims that the vftable is not found. Luckily, we
|
||||||
# could move the definition into the source file to solve the problem.
|
# could move the definition into the source file to solve the problem.
|
||||||
list(LENGTH NAMESPACES ns_count)
|
list(LENGTH NAMESPACES ns_count)
|
||||||
if ("${FILENAME}" MATCHES ".pb.h" AND ns_count EQUAL 1)
|
if("${FILENAME}" MATCHES ".pb.h" AND ns_count EQUAL 1)
|
||||||
string(REPLACE ".pb.h" ".pb.cc" SOURCE_FILENAME ${FILENAME})
|
string(REPLACE ".pb.h" ".pb.cc" SOURCE_FILENAME ${FILENAME})
|
||||||
file(READ ${SOURCE_FILENAME} content_cc_origin)
|
file(READ ${SOURCE_FILENAME} content_cc_origin)
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
|
|
||||||
if (DEFINED ENV{TORCH_INSTALL_PREFIX})
|
if(DEFINED ENV{TORCH_INSTALL_PREFIX})
|
||||||
set(TORCH_INSTALL_PREFIX $ENV{TORCH_INSTALL_PREFIX})
|
set(TORCH_INSTALL_PREFIX $ENV{TORCH_INSTALL_PREFIX})
|
||||||
else()
|
else()
|
||||||
# Assume we are in <install-prefix>/share/cmake/Torch/TorchConfig.cmake
|
# Assume we are in <install-prefix>/share/cmake/Torch/TorchConfig.cmake
|
||||||
@ -25,7 +25,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Include directories.
|
# Include directories.
|
||||||
if (EXISTS "${TORCH_INSTALL_PREFIX}/include")
|
if(EXISTS "${TORCH_INSTALL_PREFIX}/include")
|
||||||
set(TORCH_INCLUDE_DIRS
|
set(TORCH_INCLUDE_DIRS
|
||||||
${TORCH_INSTALL_PREFIX}/include
|
${TORCH_INSTALL_PREFIX}/include
|
||||||
${TORCH_INSTALL_PREFIX}/include/torch/csrc/api/include)
|
${TORCH_INSTALL_PREFIX}/include/torch/csrc/api/include)
|
||||||
@ -36,7 +36,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Library dependencies.
|
# Library dependencies.
|
||||||
if (@BUILD_SHARED_LIBS@)
|
if(@BUILD_SHARED_LIBS@)
|
||||||
find_package(Caffe2 REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR}/../Caffe2)
|
find_package(Caffe2 REQUIRED PATHS ${CMAKE_CURRENT_LIST_DIR}/../Caffe2)
|
||||||
set(TORCH_LIBRARIES torch ${Caffe2_MAIN_LIBS})
|
set(TORCH_LIBRARIES torch ${Caffe2_MAIN_LIBS})
|
||||||
else()
|
else()
|
||||||
@ -50,26 +50,26 @@ list(APPEND TORCH_LIBRARIES ${C10_LIBRARY})
|
|||||||
# We need manually add dependent libraries when they are not linked into the
|
# We need manually add dependent libraries when they are not linked into the
|
||||||
# shared library.
|
# shared library.
|
||||||
# TODO: this list might be incomplete.
|
# TODO: this list might be incomplete.
|
||||||
if (NOT @BUILD_SHARED_LIBS@)
|
if(NOT @BUILD_SHARED_LIBS@)
|
||||||
find_library(TORCH_CPU_LIBRARY torch_cpu PATHS "${TORCH_INSTALL_PREFIX}/lib")
|
find_library(TORCH_CPU_LIBRARY torch_cpu PATHS "${TORCH_INSTALL_PREFIX}/lib")
|
||||||
list(APPEND TORCH_LIBRARIES ${TORCH_CPU_LIBRARY})
|
list(APPEND TORCH_LIBRARIES ${TORCH_CPU_LIBRARY})
|
||||||
|
|
||||||
if (@USE_NNPACK@)
|
if(@USE_NNPACK@)
|
||||||
find_library(NNPACK_LIBRARY nnpack PATHS "${TORCH_INSTALL_PREFIX}/lib")
|
find_library(NNPACK_LIBRARY nnpack PATHS "${TORCH_INSTALL_PREFIX}/lib")
|
||||||
list(APPEND TORCH_LIBRARIES ${NNPACK_LIBRARY})
|
list(APPEND TORCH_LIBRARIES ${NNPACK_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (@USE_PYTORCH_QNNPACK@)
|
if(@USE_PYTORCH_QNNPACK@)
|
||||||
find_library(PYTORCH_QNNPACK_LIBRARY pytorch_qnnpack PATHS "${TORCH_INSTALL_PREFIX}/lib")
|
find_library(PYTORCH_QNNPACK_LIBRARY pytorch_qnnpack PATHS "${TORCH_INSTALL_PREFIX}/lib")
|
||||||
list(APPEND TORCH_LIBRARIES ${PYTORCH_QNNPACK_LIBRARY})
|
list(APPEND TORCH_LIBRARIES ${PYTORCH_QNNPACK_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (@USE_XNNPACK@)
|
if(@USE_XNNPACK@)
|
||||||
find_library(XNNPACK_LIBRARY XNNPACK PATHS "${TORCH_INSTALL_PREFIX}/lib")
|
find_library(XNNPACK_LIBRARY XNNPACK PATHS "${TORCH_INSTALL_PREFIX}/lib")
|
||||||
list(APPEND TORCH_LIBRARIES ${XNNPACK_LIBRARY})
|
list(APPEND TORCH_LIBRARIES ${XNNPACK_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (@INTERN_USE_EIGEN_BLAS@)
|
if(@INTERN_USE_EIGEN_BLAS@)
|
||||||
find_library(EIGEN_BLAS_LIBRARY eigen_blas PATHS "${TORCH_INSTALL_PREFIX}/lib")
|
find_library(EIGEN_BLAS_LIBRARY eigen_blas PATHS "${TORCH_INSTALL_PREFIX}/lib")
|
||||||
list(APPEND TORCH_LIBRARIES ${EIGEN_BLAS_LIBRARY})
|
list(APPEND TORCH_LIBRARIES ${EIGEN_BLAS_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
@ -81,10 +81,10 @@ if (NOT @BUILD_SHARED_LIBS@)
|
|||||||
list(APPEND TORCH_LIBRARIES ${CLOG_LIBRARY})
|
list(APPEND TORCH_LIBRARIES ${CLOG_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (@USE_CUDA@)
|
if(@USE_CUDA@)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
set(NVTOOLEXT_HOME "C:/Program Files/NVIDIA Corporation/NvToolsExt")
|
set(NVTOOLEXT_HOME "C:/Program Files/NVIDIA Corporation/NvToolsExt")
|
||||||
if ($ENV{NVTOOLEXT_HOME})
|
if($ENV{NVTOOLEXT_HOME})
|
||||||
set(NVTOOLEXT_HOME $ENV{NVTOOLEXT_HOME})
|
set(NVTOOLEXT_HOME $ENV{NVTOOLEXT_HOME})
|
||||||
endif()
|
endif()
|
||||||
set(TORCH_CUDA_LIBRARIES
|
set(TORCH_CUDA_LIBRARIES
|
||||||
@ -113,7 +113,7 @@ if (@USE_CUDA@)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# When we build libtorch with the old GCC ABI, dependent libraries must too.
|
# When we build libtorch with the old GCC ABI, dependent libraries must too.
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
set(TORCH_CXX_FLAGS "-D_GLIBCXX_USE_CXX11_ABI=@GLIBCXX_USE_CXX11_ABI@")
|
set(TORCH_CXX_FLAGS "-D_GLIBCXX_USE_CXX11_ABI=@GLIBCXX_USE_CXX11_ABI@")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ set_target_properties(torch PROPERTIES
|
|||||||
INTERFACE_INCLUDE_DIRECTORIES "${TORCH_INCLUDE_DIRS}"
|
INTERFACE_INCLUDE_DIRECTORIES "${TORCH_INCLUDE_DIRS}"
|
||||||
CXX_STANDARD 14
|
CXX_STANDARD 14
|
||||||
)
|
)
|
||||||
if (TORCH_CXX_FLAGS)
|
if(TORCH_CXX_FLAGS)
|
||||||
set_property(TARGET torch PROPERTY INTERFACE_COMPILE_OPTIONS "${TORCH_CXX_FLAGS}")
|
set_property(TARGET torch PROPERTY INTERFACE_COMPILE_OPTIONS "${TORCH_CXX_FLAGS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
|
|||||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||||
else()
|
else()
|
||||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||||
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
|
if("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
|
||||||
set(PACKAGE_VERSION_EXACT TRUE)
|
set(PACKAGE_VERSION_EXACT TRUE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -142,7 +142,7 @@ endfunction()
|
|||||||
#
|
#
|
||||||
function(dedent outvar text)
|
function(dedent outvar text)
|
||||||
# Use PYTHON_EXECUTABLE if it is defined, otherwise default to python
|
# Use PYTHON_EXECUTABLE if it is defined, otherwise default to python
|
||||||
if ("${PYTHON_EXECUTABLE}" STREQUAL "")
|
if("${PYTHON_EXECUTABLE}" STREQUAL "")
|
||||||
set(_python_exe "python")
|
set(_python_exe "python")
|
||||||
else()
|
else()
|
||||||
set(_python_exe "${PYTHON_EXECUTABLE}")
|
set(_python_exe "${PYTHON_EXECUTABLE}")
|
||||||
@ -167,7 +167,7 @@ endfunction()
|
|||||||
|
|
||||||
function(pycmd_no_exit outvar exitcode cmd)
|
function(pycmd_no_exit outvar exitcode cmd)
|
||||||
# Use PYTHON_EXECUTABLE if it is defined, otherwise default to python
|
# Use PYTHON_EXECUTABLE if it is defined, otherwise default to python
|
||||||
if ("${PYTHON_EXECUTABLE}" STREQUAL "")
|
if("${PYTHON_EXECUTABLE}" STREQUAL "")
|
||||||
set(_python_exe "python")
|
set(_python_exe "python")
|
||||||
else()
|
else()
|
||||||
set(_python_exe "${PYTHON_EXECUTABLE}")
|
set(_python_exe "${PYTHON_EXECUTABLE}")
|
||||||
@ -232,7 +232,7 @@ function(print_target_properties tgt)
|
|||||||
foreach (prop ${CMAKE_PROPERTY_LIST})
|
foreach (prop ${CMAKE_PROPERTY_LIST})
|
||||||
string(REPLACE "<CONFIG>" "${CMAKE_BUILD_TYPE}" prop ${prop})
|
string(REPLACE "<CONFIG>" "${CMAKE_BUILD_TYPE}" prop ${prop})
|
||||||
get_property(propval TARGET ${tgt} PROPERTY ${prop} SET)
|
get_property(propval TARGET ${tgt} PROPERTY ${prop} SET)
|
||||||
if (propval)
|
if(propval)
|
||||||
get_target_property(propval ${tgt} ${prop})
|
get_target_property(propval ${tgt} ${prop})
|
||||||
message ("${tgt} ${prop} = ${propval}")
|
message ("${tgt} ${prop} = ${propval}")
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
|
|
||||||
if (__caffe2_whitelist_included)
|
if(__caffe2_whitelist_included)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set (__caffe2_whitelist_included TRUE)
|
set (__caffe2_whitelist_included TRUE)
|
||||||
|
|
||||||
set(CAFFE2_WHITELISTED_FILES)
|
set(CAFFE2_WHITELISTED_FILES)
|
||||||
if (NOT CAFFE2_WHITELIST)
|
if(NOT CAFFE2_WHITELIST)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ macro(caffe2_do_whitelist output whitelist)
|
|||||||
set(_tmp)
|
set(_tmp)
|
||||||
foreach(item ${${output}})
|
foreach(item ${${output}})
|
||||||
list(FIND ${whitelist} ${item} _index)
|
list(FIND ${whitelist} ${item} _index)
|
||||||
if (${_index} GREATER -1)
|
if(${_index} GREATER -1)
|
||||||
set(_tmp ${_tmp} ${item})
|
set(_tmp ${_tmp} ${item})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -2,9 +2,9 @@ if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
|||||||
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||||
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||||
|
|
||||||
if (NOT DEFINED CMAKE_INSTALL_PREFIX)
|
if(NOT DEFINED CMAKE_INSTALL_PREFIX)
|
||||||
set (CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@")
|
set (CMAKE_INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@")
|
||||||
endif ()
|
endif()
|
||||||
message(${CMAKE_INSTALL_PREFIX})
|
message(${CMAKE_INSTALL_PREFIX})
|
||||||
|
|
||||||
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||||
|
@ -40,10 +40,10 @@ set (CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment
|
|||||||
|
|
||||||
# Determine the cmake host system version so we know where to find the iOS SDKs
|
# Determine the cmake host system version so we know where to find the iOS SDKs
|
||||||
find_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin)
|
find_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin)
|
||||||
if (CMAKE_UNAME)
|
if(CMAKE_UNAME)
|
||||||
exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION)
|
exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION)
|
||||||
string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
|
string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
|
||||||
endif (CMAKE_UNAME)
|
endif(CMAKE_UNAME)
|
||||||
|
|
||||||
# Force the compilers to gcc for iOS
|
# Force the compilers to gcc for iOS
|
||||||
set(CMAKE_C_COMPILER /usr/bin/gcc CACHE STRING "")
|
set(CMAKE_C_COMPILER /usr/bin/gcc CACHE STRING "")
|
||||||
@ -53,35 +53,35 @@ set(CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE)
|
|||||||
set(PKG_CONFIG_EXECUTABLE pkg-config CACHE FILEPATH "" FORCE)
|
set(PKG_CONFIG_EXECUTABLE pkg-config CACHE FILEPATH "" FORCE)
|
||||||
|
|
||||||
# Setup iOS platform unless specified manually with IOS_PLATFORM
|
# Setup iOS platform unless specified manually with IOS_PLATFORM
|
||||||
if (NOT DEFINED IOS_PLATFORM)
|
if(NOT DEFINED IOS_PLATFORM)
|
||||||
set (IOS_PLATFORM "OS")
|
set (IOS_PLATFORM "OS")
|
||||||
endif (NOT DEFINED IOS_PLATFORM)
|
endif(NOT DEFINED IOS_PLATFORM)
|
||||||
set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform")
|
set (IOS_PLATFORM ${IOS_PLATFORM} CACHE STRING "Type of iOS Platform")
|
||||||
|
|
||||||
# Check the platform selection and setup for developer root
|
# Check the platform selection and setup for developer root
|
||||||
if (${IOS_PLATFORM} STREQUAL "OS")
|
if(${IOS_PLATFORM} STREQUAL "OS")
|
||||||
set (IOS_PLATFORM_LOCATION "iPhoneOS.platform")
|
set (IOS_PLATFORM_LOCATION "iPhoneOS.platform")
|
||||||
set (XCODE_IOS_PLATFORM iphoneos)
|
set (XCODE_IOS_PLATFORM iphoneos)
|
||||||
|
|
||||||
# This causes the installers to properly locate the output libraries
|
# This causes the installers to properly locate the output libraries
|
||||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos")
|
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos")
|
||||||
elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR")
|
elseif(${IOS_PLATFORM} STREQUAL "SIMULATOR")
|
||||||
set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
|
set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
|
||||||
set (XCODE_IOS_PLATFORM iphonesimulator)
|
set (XCODE_IOS_PLATFORM iphonesimulator)
|
||||||
|
|
||||||
# This causes the installers to properly locate the output libraries
|
# This causes the installers to properly locate the output libraries
|
||||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
|
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
|
||||||
elseif (${IOS_PLATFORM} STREQUAL "WATCHOS")
|
elseif(${IOS_PLATFORM} STREQUAL "WATCHOS")
|
||||||
set (IOS_PLATFORM_LOCATION "WatchOS.platform")
|
set (IOS_PLATFORM_LOCATION "WatchOS.platform")
|
||||||
set (XCODE_IOS_PLATFORM watchos)
|
set (XCODE_IOS_PLATFORM watchos)
|
||||||
|
|
||||||
# This causes the installers to properly locate the output libraries
|
# This causes the installers to properly locate the output libraries
|
||||||
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-watchos")
|
set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-watchos")
|
||||||
else (${IOS_PLATFORM} STREQUAL "OS")
|
else(${IOS_PLATFORM} STREQUAL "OS")
|
||||||
message (FATAL_ERROR
|
message (FATAL_ERROR
|
||||||
"Unsupported IOS_PLATFORM value selected. "
|
"Unsupported IOS_PLATFORM value selected. "
|
||||||
"Please choose OS, SIMULATOR, or WATCHOS.")
|
"Please choose OS, SIMULATOR, or WATCHOS.")
|
||||||
endif ()
|
endif()
|
||||||
|
|
||||||
# All iOS/Darwin specific settings - some may be redundant
|
# All iOS/Darwin specific settings - some may be redundant
|
||||||
set (CMAKE_SHARED_LIBRARY_PREFIX "lib")
|
set (CMAKE_SHARED_LIBRARY_PREFIX "lib")
|
||||||
@ -96,7 +96,7 @@ set (CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
|
|||||||
set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
|
set (CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
|
||||||
set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
|
set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
|
||||||
|
|
||||||
if (IOS_DEPLOYMENT_TARGET)
|
if(IOS_DEPLOYMENT_TARGET)
|
||||||
set(XCODE_IOS_PLATFORM_VERSION_FLAGS "-m${XCODE_IOS_PLATFORM}-version-min=${IOS_DEPLOYMENT_TARGET}")
|
set(XCODE_IOS_PLATFORM_VERSION_FLAGS "-m${XCODE_IOS_PLATFORM}-version-min=${IOS_DEPLOYMENT_TARGET}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -118,9 +118,9 @@ set (CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a")
|
|||||||
# (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache
|
# (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache
|
||||||
# and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun)
|
# and still cmake didn't fail in CMakeFindBinUtils.cmake (because it isn't rerun)
|
||||||
# hardcode CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did before, Alex
|
# hardcode CMAKE_INSTALL_NAME_TOOL here to install_name_tool, so it behaves as it did before, Alex
|
||||||
if (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
if(NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
||||||
find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
|
find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
|
||||||
endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
endif(NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
|
||||||
|
|
||||||
# Setup iOS deployment target
|
# Setup iOS deployment target
|
||||||
set (IOS_DEPLOYMENT_TARGET ${IOS_DEPLOYMENT_TARGET} CACHE STRING "Minimum iOS version")
|
set (IOS_DEPLOYMENT_TARGET ${IOS_DEPLOYMENT_TARGET} CACHE STRING "Minimum iOS version")
|
||||||
@ -130,40 +130,40 @@ set (IOS_DEPLOYMENT_TARGET ${IOS_DEPLOYMENT_TARGET} CACHE STRING "Minimum iOS ve
|
|||||||
exec_program(/usr/bin/xcode-select ARGS -print-path OUTPUT_VARIABLE CMAKE_XCODE_DEVELOPER_DIR)
|
exec_program(/usr/bin/xcode-select ARGS -print-path OUTPUT_VARIABLE CMAKE_XCODE_DEVELOPER_DIR)
|
||||||
set (XCODE_POST_43_ROOT "${CMAKE_XCODE_DEVELOPER_DIR}/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
|
set (XCODE_POST_43_ROOT "${CMAKE_XCODE_DEVELOPER_DIR}/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
|
||||||
set (XCODE_PRE_43_ROOT "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
|
set (XCODE_PRE_43_ROOT "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
|
||||||
if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
|
if(NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
|
||||||
if (EXISTS ${XCODE_POST_43_ROOT})
|
if(EXISTS ${XCODE_POST_43_ROOT})
|
||||||
set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT})
|
set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT})
|
||||||
elseif(EXISTS ${XCODE_PRE_43_ROOT})
|
elseif(EXISTS ${XCODE_PRE_43_ROOT})
|
||||||
set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT})
|
set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT})
|
||||||
endif (EXISTS ${XCODE_POST_43_ROOT})
|
endif(EXISTS ${XCODE_POST_43_ROOT})
|
||||||
endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
|
endif(NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
|
||||||
set (CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform")
|
set (CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform")
|
||||||
|
|
||||||
# Find and use the most recent iOS sdk unless specified manually with CMAKE_IOS_SDK_ROOT
|
# Find and use the most recent iOS sdk unless specified manually with CMAKE_IOS_SDK_ROOT
|
||||||
if (NOT DEFINED CMAKE_IOS_SDK_ROOT)
|
if(NOT DEFINED CMAKE_IOS_SDK_ROOT)
|
||||||
file (GLOB _CMAKE_IOS_SDKS "${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*")
|
file (GLOB _CMAKE_IOS_SDKS "${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*")
|
||||||
if (_CMAKE_IOS_SDKS)
|
if(_CMAKE_IOS_SDKS)
|
||||||
list (SORT _CMAKE_IOS_SDKS)
|
list (SORT _CMAKE_IOS_SDKS)
|
||||||
list (REVERSE _CMAKE_IOS_SDKS)
|
list (REVERSE _CMAKE_IOS_SDKS)
|
||||||
list (GET _CMAKE_IOS_SDKS 0 CMAKE_IOS_SDK_ROOT)
|
list (GET _CMAKE_IOS_SDKS 0 CMAKE_IOS_SDK_ROOT)
|
||||||
else (_CMAKE_IOS_SDKS)
|
else(_CMAKE_IOS_SDKS)
|
||||||
message (FATAL_ERROR "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.")
|
message (FATAL_ERROR "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.")
|
||||||
endif (_CMAKE_IOS_SDKS)
|
endif(_CMAKE_IOS_SDKS)
|
||||||
message (STATUS "Toolchain using default iOS SDK: ${CMAKE_IOS_SDK_ROOT}")
|
message (STATUS "Toolchain using default iOS SDK: ${CMAKE_IOS_SDK_ROOT}")
|
||||||
endif (NOT DEFINED CMAKE_IOS_SDK_ROOT)
|
endif(NOT DEFINED CMAKE_IOS_SDK_ROOT)
|
||||||
set (CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK")
|
set (CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK")
|
||||||
|
|
||||||
# Set the sysroot default to the most recent SDK
|
# Set the sysroot default to the most recent SDK
|
||||||
set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
|
set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
|
||||||
|
|
||||||
# set the architecture for iOS
|
# set the architecture for iOS
|
||||||
if (IOS_PLATFORM STREQUAL "OS")
|
if(IOS_PLATFORM STREQUAL "OS")
|
||||||
set (DEFAULT_IOS_ARCH "arm64")
|
set (DEFAULT_IOS_ARCH "arm64")
|
||||||
elseif (IOS_PLATFORM STREQUAL "SIMULATOR")
|
elseif(IOS_PLATFORM STREQUAL "SIMULATOR")
|
||||||
set (DEFAULT_IOS_ARCH "x86_64")
|
set (DEFAULT_IOS_ARCH "x86_64")
|
||||||
elseif (IOS_PLATFORM STREQUAL "WATCHOS")
|
elseif(IOS_PLATFORM STREQUAL "WATCHOS")
|
||||||
set (DEFAULT_IOS_ARCH "armv7k;arm64_32")
|
set (DEFAULT_IOS_ARCH "armv7k;arm64_32")
|
||||||
endif ()
|
endif()
|
||||||
|
|
||||||
set (IOS_ARCH ${DEFAULT_IOS_ARCH} CACHE string "Build architecture for iOS")
|
set (IOS_ARCH ${DEFAULT_IOS_ARCH} CACHE string "Build architecture for iOS")
|
||||||
set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE string "Build architecture for iOS")
|
set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE string "Build architecture for iOS")
|
||||||
|
@ -1,125 +1,125 @@
|
|||||||
set(PYTORCH_FOUND_HIP FALSE)
|
set(PYTORCH_FOUND_HIP FALSE)
|
||||||
|
|
||||||
IF(NOT DEFINED ENV{ROCM_PATH})
|
if(NOT DEFINED ENV{ROCM_PATH})
|
||||||
SET(ROCM_PATH /opt/rocm)
|
SET(ROCM_PATH /opt/rocm)
|
||||||
ELSE()
|
else()
|
||||||
SET(ROCM_PATH $ENV{ROCM_PATH})
|
SET(ROCM_PATH $ENV{ROCM_PATH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# HIP_PATH
|
# HIP_PATH
|
||||||
IF(NOT DEFINED ENV{HIP_PATH})
|
if(NOT DEFINED ENV{HIP_PATH})
|
||||||
SET(HIP_PATH ${ROCM_PATH}/hip)
|
SET(HIP_PATH ${ROCM_PATH}/hip)
|
||||||
ELSE()
|
else()
|
||||||
SET(HIP_PATH $ENV{HIP_PATH})
|
SET(HIP_PATH $ENV{HIP_PATH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF(NOT EXISTS ${HIP_PATH})
|
if(NOT EXISTS ${HIP_PATH})
|
||||||
return()
|
return()
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# HCC_PATH
|
# HCC_PATH
|
||||||
IF(NOT DEFINED ENV{HCC_PATH})
|
if(NOT DEFINED ENV{HCC_PATH})
|
||||||
SET(HCC_PATH ${ROCM_PATH}/hcc)
|
SET(HCC_PATH ${ROCM_PATH}/hcc)
|
||||||
ELSE()
|
else()
|
||||||
SET(HCC_PATH $ENV{HCC_PATH})
|
SET(HCC_PATH $ENV{HCC_PATH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# HSA_PATH
|
# HSA_PATH
|
||||||
IF(NOT DEFINED ENV{HSA_PATH})
|
if(NOT DEFINED ENV{HSA_PATH})
|
||||||
SET(HSA_PATH ${ROCM_PATH}/hsa)
|
SET(HSA_PATH ${ROCM_PATH}/hsa)
|
||||||
ELSE()
|
else()
|
||||||
SET(HSA_PATH $ENV{HSA_PATH})
|
SET(HSA_PATH $ENV{HSA_PATH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# ROCBLAS_PATH
|
# ROCBLAS_PATH
|
||||||
IF(NOT DEFINED ENV{ROCBLAS_PATH})
|
if(NOT DEFINED ENV{ROCBLAS_PATH})
|
||||||
SET(ROCBLAS_PATH ${ROCM_PATH}/rocblas)
|
SET(ROCBLAS_PATH ${ROCM_PATH}/rocblas)
|
||||||
ELSE()
|
else()
|
||||||
SET(ROCBLAS_PATH $ENV{ROCBLAS_PATH})
|
SET(ROCBLAS_PATH $ENV{ROCBLAS_PATH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# ROCFFT_PATH
|
# ROCFFT_PATH
|
||||||
IF(NOT DEFINED ENV{ROCFFT_PATH})
|
if(NOT DEFINED ENV{ROCFFT_PATH})
|
||||||
SET(ROCFFT_PATH ${ROCM_PATH}/rocfft)
|
SET(ROCFFT_PATH ${ROCM_PATH}/rocfft)
|
||||||
ELSE()
|
else()
|
||||||
SET(ROCFFT_PATH $ENV{ROCFFT_PATH})
|
SET(ROCFFT_PATH $ENV{ROCFFT_PATH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# HIPSPARSE_PATH
|
# HIPSPARSE_PATH
|
||||||
IF(NOT DEFINED ENV{HIPSPARSE_PATH})
|
if(NOT DEFINED ENV{HIPSPARSE_PATH})
|
||||||
SET(HIPSPARSE_PATH ${ROCM_PATH}/hipsparse)
|
SET(HIPSPARSE_PATH ${ROCM_PATH}/hipsparse)
|
||||||
ELSE()
|
else()
|
||||||
SET(HIPSPARSE_PATH $ENV{HIPSPARSE_PATH})
|
SET(HIPSPARSE_PATH $ENV{HIPSPARSE_PATH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# THRUST_PATH
|
# THRUST_PATH
|
||||||
IF(DEFINED ENV{THRUST_PATH})
|
if(DEFINED ENV{THRUST_PATH})
|
||||||
SET(THRUST_PATH $ENV{THRUST_PATH})
|
SET(THRUST_PATH $ENV{THRUST_PATH})
|
||||||
ELSE()
|
else()
|
||||||
SET(THRUST_PATH ${ROCM_PATH}/include)
|
SET(THRUST_PATH ${ROCM_PATH}/include)
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# HIPRAND_PATH
|
# HIPRAND_PATH
|
||||||
IF(NOT DEFINED ENV{HIPRAND_PATH})
|
if(NOT DEFINED ENV{HIPRAND_PATH})
|
||||||
SET(HIPRAND_PATH ${ROCM_PATH}/hiprand)
|
SET(HIPRAND_PATH ${ROCM_PATH}/hiprand)
|
||||||
ELSE()
|
else()
|
||||||
SET(HIPRAND_PATH $ENV{HIPRAND_PATH})
|
SET(HIPRAND_PATH $ENV{HIPRAND_PATH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# ROCRAND_PATH
|
# ROCRAND_PATH
|
||||||
IF(NOT DEFINED ENV{ROCRAND_PATH})
|
if(NOT DEFINED ENV{ROCRAND_PATH})
|
||||||
SET(ROCRAND_PATH ${ROCM_PATH}/rocrand)
|
SET(ROCRAND_PATH ${ROCM_PATH}/rocrand)
|
||||||
ELSE()
|
else()
|
||||||
SET(ROCRAND_PATH $ENV{ROCRAND_PATH})
|
SET(ROCRAND_PATH $ENV{ROCRAND_PATH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# MIOPEN_PATH
|
# MIOPEN_PATH
|
||||||
IF(NOT DEFINED ENV{MIOPEN_PATH})
|
if(NOT DEFINED ENV{MIOPEN_PATH})
|
||||||
SET(MIOPEN_PATH ${ROCM_PATH}/miopen)
|
SET(MIOPEN_PATH ${ROCM_PATH}/miopen)
|
||||||
ELSE()
|
else()
|
||||||
SET(MIOPEN_PATH $ENV{MIOPEN_PATH})
|
SET(MIOPEN_PATH $ENV{MIOPEN_PATH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# RCCL_PATH
|
# RCCL_PATH
|
||||||
IF(NOT DEFINED ENV{RCCL_PATH})
|
if(NOT DEFINED ENV{RCCL_PATH})
|
||||||
SET(RCCL_PATH ${ROCM_PATH}/rccl)
|
SET(RCCL_PATH ${ROCM_PATH}/rccl)
|
||||||
ELSE()
|
else()
|
||||||
SET(RCCL_PATH $ENV{RCCL_PATH})
|
SET(RCCL_PATH $ENV{RCCL_PATH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# ROCPRIM_PATH
|
# ROCPRIM_PATH
|
||||||
IF(NOT DEFINED ENV{ROCPRIM_PATH})
|
if(NOT DEFINED ENV{ROCPRIM_PATH})
|
||||||
SET(ROCPRIM_PATH ${ROCM_PATH}/rocprim)
|
SET(ROCPRIM_PATH ${ROCM_PATH}/rocprim)
|
||||||
ELSE()
|
else()
|
||||||
SET(ROCPRIM_PATH $ENV{ROCPRIM_PATH})
|
SET(ROCPRIM_PATH $ENV{ROCPRIM_PATH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# HIPCUB_PATH
|
# HIPCUB_PATH
|
||||||
IF(NOT DEFINED ENV{HIPCUB_PATH})
|
if(NOT DEFINED ENV{HIPCUB_PATH})
|
||||||
SET(HIPCUB_PATH ${ROCM_PATH}/hipcub)
|
SET(HIPCUB_PATH ${ROCM_PATH}/hipcub)
|
||||||
ELSE()
|
else()
|
||||||
SET(HIPCUB_PATH $ENV{HIPCUB_PATH})
|
SET(HIPCUB_PATH $ENV{HIPCUB_PATH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# ROCTHRUST_PATH
|
# ROCTHRUST_PATH
|
||||||
IF(NOT DEFINED ENV{ROCTHRUST_PATH})
|
if(NOT DEFINED ENV{ROCTHRUST_PATH})
|
||||||
SET(ROCTHRUST_PATH ${ROCM_PATH}/rocthrust)
|
SET(ROCTHRUST_PATH ${ROCM_PATH}/rocthrust)
|
||||||
ELSE()
|
else()
|
||||||
SET(ROCTHRUST_PATH $ENV{ROCTHRUST_PATH})
|
SET(ROCTHRUST_PATH $ENV{ROCTHRUST_PATH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# ROCTRACER_PATH
|
# ROCTRACER_PATH
|
||||||
IF(NOT DEFINED ENV{ROCTRACER_PATH})
|
if(NOT DEFINED ENV{ROCTRACER_PATH})
|
||||||
SET(ROCTRACER_PATH ${ROCM_PATH}/roctracer)
|
SET(ROCTRACER_PATH ${ROCM_PATH}/roctracer)
|
||||||
ELSE()
|
else()
|
||||||
SET(ROCTRACER_PATH $ENV{ROCTRACER_PATH})
|
SET(ROCTRACER_PATH $ENV{ROCTRACER_PATH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
IF(NOT DEFINED ENV{PYTORCH_ROCM_ARCH})
|
if(NOT DEFINED ENV{PYTORCH_ROCM_ARCH})
|
||||||
SET(PYTORCH_ROCM_ARCH gfx803;gfx900;gfx906;gfx908)
|
SET(PYTORCH_ROCM_ARCH gfx803;gfx900;gfx906;gfx908)
|
||||||
ELSE()
|
else()
|
||||||
SET(PYTORCH_ROCM_ARCH $ENV{PYTORCH_ROCM_ARCH})
|
SET(PYTORCH_ROCM_ARCH $ENV{PYTORCH_ROCM_ARCH})
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# Add HIP to the CMAKE Module Path
|
# Add HIP to the CMAKE Module Path
|
||||||
set(CMAKE_MODULE_PATH ${HIP_PATH}/cmake ${CMAKE_MODULE_PATH})
|
set(CMAKE_MODULE_PATH ${HIP_PATH}/cmake ${CMAKE_MODULE_PATH})
|
||||||
@ -135,7 +135,7 @@ endmacro()
|
|||||||
# Find the HIP Package
|
# Find the HIP Package
|
||||||
find_package_and_print_version(HIP 1.0)
|
find_package_and_print_version(HIP 1.0)
|
||||||
|
|
||||||
IF(HIP_FOUND)
|
if(HIP_FOUND)
|
||||||
set(PYTORCH_FOUND_HIP TRUE)
|
set(PYTORCH_FOUND_HIP TRUE)
|
||||||
|
|
||||||
message("\n***** Library versions from dpkg *****\n")
|
message("\n***** Library versions from dpkg *****\n")
|
||||||
@ -196,4 +196,4 @@ IF(HIP_FOUND)
|
|||||||
set(hcc_INCLUDE_DIRS ${HCC_PATH}/include)
|
set(hcc_INCLUDE_DIRS ${HCC_PATH}/include)
|
||||||
set(hsa_INCLUDE_DIRS ${HSA_PATH}/include)
|
set(hsa_INCLUDE_DIRS ${HSA_PATH}/include)
|
||||||
|
|
||||||
ENDIF()
|
endif()
|
||||||
|
@ -21,7 +21,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../Modules_CUDA_fix)
|
|||||||
# More details can be found in the following links.
|
# More details can be found in the following links.
|
||||||
# https://github.com/pytorch/pytorch/issues/20635
|
# https://github.com/pytorch/pytorch/issues/20635
|
||||||
# https://github.com/pytorch/pytorch/issues/17108
|
# https://github.com/pytorch/pytorch/issues/17108
|
||||||
if (NOT MSVC)
|
if(NOT MSVC)
|
||||||
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE INTERNAL "")
|
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF CACHE INTERNAL "")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ if(CAFFE2_STATIC_LINK_CUDA)
|
|||||||
set_property(
|
set_property(
|
||||||
TARGET torch::cudart PROPERTY INTERFACE_LINK_LIBRARIES
|
TARGET torch::cudart PROPERTY INTERFACE_LINK_LIBRARIES
|
||||||
"${CUDA_cudart_static_LIBRARY}")
|
"${CUDA_cudart_static_LIBRARY}")
|
||||||
if (NOT WIN32)
|
if(NOT WIN32)
|
||||||
set_property(
|
set_property(
|
||||||
TARGET torch::cudart APPEND PROPERTY INTERFACE_LINK_LIBRARIES
|
TARGET torch::cudart APPEND PROPERTY INTERFACE_LINK_LIBRARIES
|
||||||
rt dl)
|
rt dl)
|
||||||
@ -291,7 +291,7 @@ if(CAFFE2_STATIC_LINK_CUDA AND NOT WIN32)
|
|||||||
set_property(
|
set_property(
|
||||||
TARGET caffe2::cublas PROPERTY INTERFACE_LINK_LIBRARIES
|
TARGET caffe2::cublas PROPERTY INTERFACE_LINK_LIBRARIES
|
||||||
"${CUDA_TOOLKIT_ROOT_DIR}/lib64/libcublas_static.a")
|
"${CUDA_TOOLKIT_ROOT_DIR}/lib64/libcublas_static.a")
|
||||||
if (CUDA_VERSION VERSION_GREATER_EQUAL 10.1)
|
if(CUDA_VERSION VERSION_GREATER_EQUAL 10.1)
|
||||||
set_property(
|
set_property(
|
||||||
TARGET caffe2::cublas APPEND PROPERTY INTERFACE_LINK_LIBRARIES
|
TARGET caffe2::cublas APPEND PROPERTY INTERFACE_LINK_LIBRARIES
|
||||||
"${CUDA_TOOLKIT_ROOT_DIR}/lib64/libcublasLt_static.a")
|
"${CUDA_TOOLKIT_ROOT_DIR}/lib64/libcublasLt_static.a")
|
||||||
@ -330,7 +330,7 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Add onnx namepsace definition to nvcc
|
# Add onnx namepsace definition to nvcc
|
||||||
if (ONNX_NAMESPACE)
|
if(ONNX_NAMESPACE)
|
||||||
list(APPEND CUDA_NVCC_FLAGS "-DONNX_NAMESPACE=${ONNX_NAMESPACE}")
|
list(APPEND CUDA_NVCC_FLAGS "-DONNX_NAMESPACE=${ONNX_NAMESPACE}")
|
||||||
else()
|
else()
|
||||||
list(APPEND CUDA_NVCC_FLAGS "-DONNX_NAMESPACE=onnx_c2")
|
list(APPEND CUDA_NVCC_FLAGS "-DONNX_NAMESPACE=onnx_c2")
|
||||||
@ -341,9 +341,9 @@ endif()
|
|||||||
# them from compiling the std::tuple header of GCC 6.
|
# them from compiling the std::tuple header of GCC 6.
|
||||||
# See Sec. 2.2.1 of
|
# See Sec. 2.2.1 of
|
||||||
# https://developer.download.nvidia.com/compute/cuda/9.2/Prod/docs/sidebar/CUDA_Toolkit_Release_Notes.pdf
|
# https://developer.download.nvidia.com/compute/cuda/9.2/Prod/docs/sidebar/CUDA_Toolkit_Release_Notes.pdf
|
||||||
if ((CUDA_VERSION VERSION_EQUAL 9.0) OR
|
if((CUDA_VERSION VERSION_EQUAL 9.0) OR
|
||||||
(CUDA_VERSION VERSION_GREATER 9.0 AND CUDA_VERSION VERSION_LESS 9.2))
|
(CUDA_VERSION VERSION_GREATER 9.0 AND CUDA_VERSION VERSION_LESS 9.2))
|
||||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND
|
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND
|
||||||
NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0 AND
|
NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0 AND
|
||||||
CUDA_HOST_COMPILER STREQUAL CMAKE_C_COMPILER)
|
CUDA_HOST_COMPILER STREQUAL CMAKE_C_COMPILER)
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
@ -357,9 +357,9 @@ endif()
|
|||||||
# CUDA 9.0 / 9.1 require MSVC version < 19.12
|
# CUDA 9.0 / 9.1 require MSVC version < 19.12
|
||||||
# CUDA 9.2 require MSVC version < 19.13
|
# CUDA 9.2 require MSVC version < 19.13
|
||||||
# CUDA 10.0 require MSVC version < 19.20
|
# CUDA 10.0 require MSVC version < 19.20
|
||||||
if ((CUDA_VERSION VERSION_EQUAL 9.0) OR
|
if((CUDA_VERSION VERSION_EQUAL 9.0) OR
|
||||||
(CUDA_VERSION VERSION_GREATER 9.0 AND CUDA_VERSION VERSION_LESS 9.2))
|
(CUDA_VERSION VERSION_GREATER 9.0 AND CUDA_VERSION VERSION_LESS 9.2))
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND
|
||||||
NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.12 AND
|
NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.12 AND
|
||||||
NOT DEFINED ENV{CUDAHOSTCXX})
|
NOT DEFINED ENV{CUDAHOSTCXX})
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
@ -371,7 +371,7 @@ if ((CUDA_VERSION VERSION_EQUAL 9.0) OR
|
|||||||
"\\2017\\Enterprise\\VC\\Tools\\MSVC\\14.11.25503\\bin\\HostX64\\x64\\cl.exe\"\n")
|
"\\2017\\Enterprise\\VC\\Tools\\MSVC\\14.11.25503\\bin\\HostX64\\x64\\cl.exe\"\n")
|
||||||
endif()
|
endif()
|
||||||
elseif(CUDA_VERSION VERSION_EQUAL 9.2)
|
elseif(CUDA_VERSION VERSION_EQUAL 9.2)
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND
|
||||||
NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.13 AND
|
NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.13 AND
|
||||||
NOT DEFINED ENV{CUDAHOSTCXX})
|
NOT DEFINED ENV{CUDAHOSTCXX})
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
@ -383,7 +383,7 @@ elseif(CUDA_VERSION VERSION_EQUAL 9.2)
|
|||||||
"\\2017\\Enterprise\\VC\\Tools\\MSVC\\14.12.25827\\bin\\HostX64\\x64\\cl.exe\"\n")
|
"\\2017\\Enterprise\\VC\\Tools\\MSVC\\14.12.25827\\bin\\HostX64\\x64\\cl.exe\"\n")
|
||||||
endif()
|
endif()
|
||||||
elseif(CUDA_VERSION VERSION_EQUAL 10.0)
|
elseif(CUDA_VERSION VERSION_EQUAL 10.0)
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND
|
||||||
NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.20 AND
|
NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.20 AND
|
||||||
NOT DEFINED ENV{CUDAHOSTCXX})
|
NOT DEFINED ENV{CUDAHOSTCXX})
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
@ -428,7 +428,7 @@ endforeach()
|
|||||||
|
|
||||||
# Set C++14 support
|
# Set C++14 support
|
||||||
set(CUDA_PROPAGATE_HOST_FLAGS_BLACKLIST "-Werror")
|
set(CUDA_PROPAGATE_HOST_FLAGS_BLACKLIST "-Werror")
|
||||||
if (MSVC)
|
if(MSVC)
|
||||||
list(APPEND CUDA_PROPAGATE_HOST_FLAGS_BLACKLIST "/EHa")
|
list(APPEND CUDA_PROPAGATE_HOST_FLAGS_BLACKLIST "/EHa")
|
||||||
else()
|
else()
|
||||||
list(APPEND CUDA_NVCC_FLAGS "-std=c++14")
|
list(APPEND CUDA_NVCC_FLAGS "-std=c++14")
|
||||||
@ -436,10 +436,10 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# OpenMP flags for NVCC with Clang-cl
|
# OpenMP flags for NVCC with Clang-cl
|
||||||
if ("${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC"
|
if("${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC"
|
||||||
AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
list(APPEND CUDA_PROPAGATE_HOST_FLAGS_BLACKLIST "-Xclang" "-fopenmp")
|
list(APPEND CUDA_PROPAGATE_HOST_FLAGS_BLACKLIST "-Xclang" "-fopenmp")
|
||||||
if (MSVC_TOOLSET_VERSION LESS 142)
|
if(MSVC_TOOLSET_VERSION LESS 142)
|
||||||
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler" "-openmp")
|
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler" "-openmp")
|
||||||
else()
|
else()
|
||||||
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler" "-openmp:experimental")
|
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler" "-openmp:experimental")
|
||||||
@ -447,13 +447,13 @@ if ("${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC"
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Debug and Release symbol support
|
# Debug and Release symbol support
|
||||||
if (MSVC)
|
if(MSVC)
|
||||||
if (${CAFFE2_USE_MSVC_STATIC_RUNTIME})
|
if(${CAFFE2_USE_MSVC_STATIC_RUNTIME})
|
||||||
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler" "-MT$<$<CONFIG:Debug>:d>")
|
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler" "-MT$<$<CONFIG:Debug>:d>")
|
||||||
else()
|
else()
|
||||||
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler" "-MD$<$<CONFIG:Debug>:d>")
|
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler" "-MD$<$<CONFIG:Debug>:d>")
|
||||||
endif()
|
endif()
|
||||||
elseif (CUDA_DEVICE_DEBUG)
|
elseif(CUDA_DEVICE_DEBUG)
|
||||||
list(APPEND CUDA_NVCC_FLAGS "-g" "-G") # -G enables device code debugging symbols
|
list(APPEND CUDA_NVCC_FLAGS "-g" "-G") # -G enables device code debugging symbols
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
# We will try to use the config mode first, and then manual find.
|
# We will try to use the config mode first, and then manual find.
|
||||||
find_package(gflags CONFIG QUIET)
|
find_package(gflags CONFIG QUIET)
|
||||||
if (NOT TARGET gflags)
|
if(NOT TARGET gflags)
|
||||||
find_package(gflags MODULE QUIET)
|
find_package(gflags MODULE QUIET)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (TARGET gflags)
|
if(TARGET gflags)
|
||||||
message(STATUS "Caffe2: Found gflags with new-style gflags target.")
|
message(STATUS "Caffe2: Found gflags with new-style gflags target.")
|
||||||
elseif(GFLAGS_FOUND)
|
elseif(GFLAGS_FOUND)
|
||||||
message(STATUS "Caffe2: Found gflags with old-style gflag starget.")
|
message(STATUS "Caffe2: Found gflags with old-style gflag starget.")
|
||||||
@ -75,7 +75,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# After above, we should have the gflags target now.
|
# After above, we should have the gflags target now.
|
||||||
if (NOT TARGET gflags)
|
if(NOT TARGET gflags)
|
||||||
message(WARNING
|
message(WARNING
|
||||||
"Caffe2: gflags cannot be found. Depending on whether you are building "
|
"Caffe2: gflags cannot be found. Depending on whether you are building "
|
||||||
"Caffe2 or a Caffe2 dependent library, the next warning / error will "
|
"Caffe2 or a Caffe2 dependent library, the next warning / error will "
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
# We will try to use the config mode first, and then manual find.
|
# We will try to use the config mode first, and then manual find.
|
||||||
find_package(glog CONFIG QUIET)
|
find_package(glog CONFIG QUIET)
|
||||||
if (NOT TARGET glog::glog)
|
if(NOT TARGET glog::glog)
|
||||||
find_package(glog MODULE QUIET)
|
find_package(glog MODULE QUIET)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (TARGET glog::glog)
|
if(TARGET glog::glog)
|
||||||
message(STATUS "Caffe2: Found glog with new-style glog target.")
|
message(STATUS "Caffe2: Found glog with new-style glog target.")
|
||||||
elseif(GLOG_FOUND)
|
elseif(GLOG_FOUND)
|
||||||
message(
|
message(
|
||||||
@ -62,7 +62,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# After above, we should have the glog::glog target now.
|
# After above, we should have the glog::glog target now.
|
||||||
if (NOT TARGET glog::glog)
|
if(NOT TARGET glog::glog)
|
||||||
message(WARNING
|
message(WARNING
|
||||||
"Caffe2: glog cannot be found. Depending on whether you are building "
|
"Caffe2: glog cannot be found. Depending on whether you are building "
|
||||||
"Caffe2 or a Caffe2 dependent library, the next warning / error will "
|
"Caffe2 or a Caffe2 dependent library, the next warning / error will "
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
# We will try to use the config mode first, and then manual find.
|
# We will try to use the config mode first, and then manual find.
|
||||||
find_package(Protobuf CONFIG QUIET)
|
find_package(Protobuf CONFIG QUIET)
|
||||||
if (NOT Protobuf_FOUND)
|
if(NOT Protobuf_FOUND)
|
||||||
find_package(Protobuf MODULE QUIET)
|
find_package(Protobuf MODULE QUIET)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if ((TARGET protobuf::libprotobuf OR TARGET protobuf::libprotobuf-lite) AND TARGET protobuf::protoc)
|
if((TARGET protobuf::libprotobuf OR TARGET protobuf::libprotobuf-lite) AND TARGET protobuf::protoc)
|
||||||
# Hooray. This is the most ideal situation, meaning that you either have a
|
# Hooray. This is the most ideal situation, meaning that you either have a
|
||||||
# Protobuf config file installed (like on Windows), or you are using a
|
# Protobuf config file installed (like on Windows), or you are using a
|
||||||
# modern CMake that ships with a FindProtobuf.cmake file that produces
|
# modern CMake that ships with a FindProtobuf.cmake file that produces
|
||||||
@ -16,7 +16,7 @@ elseif(Protobuf_FOUND OR PROTOBUF_FOUND)
|
|||||||
# If the modern targets are not present, we will generate them for you for
|
# If the modern targets are not present, we will generate them for you for
|
||||||
# backward compatibility. This is backported from CMake's new FindProtobuf.cmake
|
# backward compatibility. This is backported from CMake's new FindProtobuf.cmake
|
||||||
# content.
|
# content.
|
||||||
if ((NOT PROTOBUF_LIBRARY) AND (NOT PROTOBUF_LITE_LIBRARY))
|
if((NOT PROTOBUF_LIBRARY) AND (NOT PROTOBUF_LITE_LIBRARY))
|
||||||
message(FATAL_ERROR
|
message(FATAL_ERROR
|
||||||
"Caffe2: Found protobuf with old style targets, but could not find targets."
|
"Caffe2: Found protobuf with old style targets, but could not find targets."
|
||||||
" PROTOBUF_LIBRARY: " ${PROTOBUF_LIBRARY}
|
" PROTOBUF_LIBRARY: " ${PROTOBUF_LIBRARY}
|
||||||
@ -27,7 +27,7 @@ elseif(Protobuf_FOUND OR PROTOBUF_FOUND)
|
|||||||
message(STATUS "Caffe2: Found protobuf with old-style protobuf targets.")
|
message(STATUS "Caffe2: Found protobuf with old-style protobuf targets.")
|
||||||
|
|
||||||
if(PROTOBUF_LIBRARY)
|
if(PROTOBUF_LIBRARY)
|
||||||
if (NOT TARGET protobuf::libprotobuf)
|
if(NOT TARGET protobuf::libprotobuf)
|
||||||
add_library(protobuf::libprotobuf UNKNOWN IMPORTED)
|
add_library(protobuf::libprotobuf UNKNOWN IMPORTED)
|
||||||
set_target_properties(protobuf::libprotobuf PROPERTIES
|
set_target_properties(protobuf::libprotobuf PROPERTIES
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${PROTOBUF_INCLUDE_DIRS}")
|
INTERFACE_INCLUDE_DIRECTORIES "${PROTOBUF_INCLUDE_DIRS}")
|
||||||
@ -51,7 +51,7 @@ elseif(Protobuf_FOUND OR PROTOBUF_FOUND)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PROTOBUF_LITE_LIBRARY)
|
if(PROTOBUF_LITE_LIBRARY)
|
||||||
if (NOT TARGET protobuf::libprotobuf-lite)
|
if(NOT TARGET protobuf::libprotobuf-lite)
|
||||||
add_library(protobuf::libprotobuf-lite UNKNOWN IMPORTED)
|
add_library(protobuf::libprotobuf-lite UNKNOWN IMPORTED)
|
||||||
set_target_properties(protobuf::libprotobuf-lite PROPERTIES
|
set_target_properties(protobuf::libprotobuf-lite PROPERTIES
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${PROTOBUF_INCLUDE_DIRS}")
|
INTERFACE_INCLUDE_DIRECTORIES "${PROTOBUF_INCLUDE_DIRS}")
|
||||||
@ -75,7 +75,7 @@ elseif(Protobuf_FOUND OR PROTOBUF_FOUND)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PROTOBUF_PROTOC_EXECUTABLE)
|
if(PROTOBUF_PROTOC_EXECUTABLE)
|
||||||
if (NOT TARGET protobuf::protoc)
|
if(NOT TARGET protobuf::protoc)
|
||||||
add_executable(protobuf::protoc IMPORTED)
|
add_executable(protobuf::protoc IMPORTED)
|
||||||
endif()
|
endif()
|
||||||
set_property(TARGET protobuf::protoc PROPERTY
|
set_property(TARGET protobuf::protoc PROPERTY
|
||||||
@ -84,7 +84,7 @@ elseif(Protobuf_FOUND OR PROTOBUF_FOUND)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# After above, we should have the protobuf related target now.
|
# After above, we should have the protobuf related target now.
|
||||||
if ((NOT TARGET protobuf::libprotobuf) AND (NOT TARGET protobuf::libprotobuf-lite))
|
if((NOT TARGET protobuf::libprotobuf) AND (NOT TARGET protobuf::libprotobuf-lite))
|
||||||
message(WARNING
|
message(WARNING
|
||||||
"Protobuf cannot be found. Depending on whether you are building Caffe2 "
|
"Protobuf cannot be found. Depending on whether you are building Caffe2 "
|
||||||
"or a Caffe2 dependent library, the next warning / error will give you "
|
"or a Caffe2 dependent library, the next warning / error will give you "
|
||||||
|
@ -44,7 +44,7 @@ macro(caffe2_interface_library SRC DST)
|
|||||||
get_target_property(__src_target_type ${SRC} TYPE)
|
get_target_property(__src_target_type ${SRC} TYPE)
|
||||||
# Depending on the type of the source library, we will set up the
|
# Depending on the type of the source library, we will set up the
|
||||||
# link command for the specific SRC library.
|
# link command for the specific SRC library.
|
||||||
if (${__src_target_type} STREQUAL "STATIC_LIBRARY")
|
if(${__src_target_type} STREQUAL "STATIC_LIBRARY")
|
||||||
# In the case of static library, we will need to add whole-static flags.
|
# In the case of static library, we will need to add whole-static flags.
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
@ -120,7 +120,7 @@ function(caffe2_binary_target target_name_or_src)
|
|||||||
# https://cmake.org/cmake/help/latest/command/function.html
|
# https://cmake.org/cmake/help/latest/command/function.html
|
||||||
# Checking that ARGC is greater than # is the only way to ensure
|
# Checking that ARGC is greater than # is the only way to ensure
|
||||||
# that ARGV# was passed to the function as an extra argument.
|
# that ARGV# was passed to the function as an extra argument.
|
||||||
if (ARGC GREATER 1)
|
if(ARGC GREATER 1)
|
||||||
set(__target ${target_name_or_src})
|
set(__target ${target_name_or_src})
|
||||||
prepend(__srcs "${CMAKE_CURRENT_SOURCE_DIR}/" "${ARGN}")
|
prepend(__srcs "${CMAKE_CURRENT_SOURCE_DIR}/" "${ARGN}")
|
||||||
else()
|
else()
|
||||||
@ -130,17 +130,17 @@ function(caffe2_binary_target target_name_or_src)
|
|||||||
add_executable(${__target} ${__srcs})
|
add_executable(${__target} ${__srcs})
|
||||||
target_link_libraries(${__target} ${Caffe2_MAIN_LIBS})
|
target_link_libraries(${__target} ${Caffe2_MAIN_LIBS})
|
||||||
# If we have Caffe2_MODULES defined, we will also link with the modules.
|
# If we have Caffe2_MODULES defined, we will also link with the modules.
|
||||||
if (DEFINED Caffe2_MODULES)
|
if(DEFINED Caffe2_MODULES)
|
||||||
target_link_libraries(${__target} ${Caffe2_MODULES})
|
target_link_libraries(${__target} ${Caffe2_MODULES})
|
||||||
endif()
|
endif()
|
||||||
if (USE_TBB)
|
if(USE_TBB)
|
||||||
target_include_directories(${__target} PUBLIC ${TBB_ROOT_DIR}/include)
|
target_include_directories(${__target} PUBLIC ${TBB_ROOT_DIR}/include)
|
||||||
endif()
|
endif()
|
||||||
install(TARGETS ${__target} DESTINATION bin)
|
install(TARGETS ${__target} DESTINATION bin)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(caffe2_hip_binary_target target_name_or_src)
|
function(caffe2_hip_binary_target target_name_or_src)
|
||||||
if (ARGC GREATER 1)
|
if(ARGC GREATER 1)
|
||||||
set(__target ${target_name_or_src})
|
set(__target ${target_name_or_src})
|
||||||
prepend(__srcs "${CMAKE_CURRENT_SOURCE_DIR}/" "${ARGN}")
|
prepend(__srcs "${CMAKE_CURRENT_SOURCE_DIR}/" "${ARGN}")
|
||||||
else()
|
else()
|
||||||
@ -160,13 +160,13 @@ endfunction()
|
|||||||
# torch_cuda_based_add_executable(cuda_target)
|
# torch_cuda_based_add_executable(cuda_target)
|
||||||
#
|
#
|
||||||
macro(torch_cuda_based_add_executable cuda_target)
|
macro(torch_cuda_based_add_executable cuda_target)
|
||||||
IF (USE_ROCM)
|
if(USE_ROCM)
|
||||||
hip_add_executable(${cuda_target} ${ARGN})
|
hip_add_executable(${cuda_target} ${ARGN})
|
||||||
ELSEIF(USE_CUDA)
|
elseif(USE_CUDA)
|
||||||
cuda_add_executable(${cuda_target} ${ARGN})
|
cuda_add_executable(${cuda_target} ${ARGN})
|
||||||
ELSE()
|
else()
|
||||||
|
|
||||||
ENDIF()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
@ -176,12 +176,12 @@ endmacro()
|
|||||||
# torch_cuda_based_add_library(cuda_target)
|
# torch_cuda_based_add_library(cuda_target)
|
||||||
#
|
#
|
||||||
macro(torch_cuda_based_add_library cuda_target)
|
macro(torch_cuda_based_add_library cuda_target)
|
||||||
IF (USE_ROCM)
|
if(USE_ROCM)
|
||||||
hip_add_library(${cuda_target} ${ARGN})
|
hip_add_library(${cuda_target} ${ARGN})
|
||||||
ELSEIF(USE_CUDA)
|
elseif(USE_CUDA)
|
||||||
cuda_add_library(${cuda_target} ${ARGN})
|
cuda_add_library(${cuda_target} ${ARGN})
|
||||||
ELSE()
|
else()
|
||||||
ENDIF()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ endmacro()
|
|||||||
#
|
#
|
||||||
macro(torch_cuda_get_nvcc_gencode_flag store_var)
|
macro(torch_cuda_get_nvcc_gencode_flag store_var)
|
||||||
# setting nvcc arch flags
|
# setting nvcc arch flags
|
||||||
if ((NOT EXISTS ${TORCH_CUDA_ARCH_LIST}) AND (DEFINED ENV{TORCH_CUDA_ARCH_LIST}))
|
if((NOT EXISTS ${TORCH_CUDA_ARCH_LIST}) AND (DEFINED ENV{TORCH_CUDA_ARCH_LIST}))
|
||||||
message(WARNING
|
message(WARNING
|
||||||
"In the future we will require one to explicitly pass "
|
"In the future we will require one to explicitly pass "
|
||||||
"TORCH_CUDA_ARCH_LIST to cmake instead of implicitly setting it as an "
|
"TORCH_CUDA_ARCH_LIST to cmake instead of implicitly setting it as an "
|
||||||
@ -200,7 +200,7 @@ macro(torch_cuda_get_nvcc_gencode_flag store_var)
|
|||||||
"pytorch.")
|
"pytorch.")
|
||||||
set(TORCH_CUDA_ARCH_LIST $ENV{TORCH_CUDA_ARCH_LIST})
|
set(TORCH_CUDA_ARCH_LIST $ENV{TORCH_CUDA_ARCH_LIST})
|
||||||
endif()
|
endif()
|
||||||
if (EXISTS ${CUDA_ARCH_NAME})
|
if(EXISTS ${CUDA_ARCH_NAME})
|
||||||
message(WARNING
|
message(WARNING
|
||||||
"CUDA_ARCH_NAME is no longer used. Use TORCH_CUDA_ARCH_LIST instead. "
|
"CUDA_ARCH_NAME is no longer used. Use TORCH_CUDA_ARCH_LIST instead. "
|
||||||
"Right now, CUDA_ARCH_NAME is ${CUDA_ARCH_NAME} and "
|
"Right now, CUDA_ARCH_NAME is ${CUDA_ARCH_NAME} and "
|
||||||
@ -220,11 +220,11 @@ endmacro()
|
|||||||
function(torch_compile_options libname)
|
function(torch_compile_options libname)
|
||||||
set_property(TARGET ${libname} PROPERTY CXX_STANDARD 14)
|
set_property(TARGET ${libname} PROPERTY CXX_STANDARD 14)
|
||||||
|
|
||||||
if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
if(NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
||||||
# until they can be unified, keep these lists synced with setup.py
|
# until they can be unified, keep these lists synced with setup.py
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
|
||||||
if (MSVC_Z7_OVERRIDE)
|
if(MSVC_Z7_OVERRIDE)
|
||||||
set(MSVC_DEBINFO_OPTION "/Z7")
|
set(MSVC_DEBINFO_OPTION "/Z7")
|
||||||
else()
|
else()
|
||||||
set(MSVC_DEBINFO_OPTION "/Zi")
|
set(MSVC_DEBINFO_OPTION "/Zi")
|
||||||
@ -271,13 +271,13 @@ function(torch_compile_options libname)
|
|||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (MSVC)
|
if(MSVC)
|
||||||
elseif (WERROR)
|
elseif(WERROR)
|
||||||
target_compile_options(${libname} PRIVATE -Werror -Wno-strict-overflow)
|
target_compile_options(${libname} PRIVATE -Werror -Wno-strict-overflow)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT WIN32 AND NOT USE_ASAN)
|
if(NOT WIN32 AND NOT USE_ASAN)
|
||||||
# Enable hidden visibility by default to make it easier to debug issues with
|
# Enable hidden visibility by default to make it easier to debug issues with
|
||||||
# TORCH_API annotations. Hidden visibility with selective default visibility
|
# TORCH_API annotations. Hidden visibility with selective default visibility
|
||||||
# behaves close enough to Windows' dllimport/dllexport.
|
# behaves close enough to Windows' dllimport/dllexport.
|
||||||
@ -293,7 +293,7 @@ function(torch_compile_options libname)
|
|||||||
|
|
||||||
# ---[ Check if warnings should be errors.
|
# ---[ Check if warnings should be errors.
|
||||||
# TODO: Dedupe with WERROR check above
|
# TODO: Dedupe with WERROR check above
|
||||||
if (WERROR)
|
if(WERROR)
|
||||||
target_compile_options(${libname} PRIVATE -Werror)
|
target_compile_options(${libname} PRIVATE -Werror)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -5,22 +5,22 @@ CMAKE_POLICY(VERSION 2.6)
|
|||||||
set(TORCH_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../)
|
set(TORCH_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../)
|
||||||
include(${TORCH_ROOT}/cmake/public/threads.cmake)
|
include(${TORCH_ROOT}/cmake/public/threads.cmake)
|
||||||
|
|
||||||
IF(NOT LIBSHM_INSTALL_LIB_SUBDIR)
|
if(NOT LIBSHM_INSTALL_LIB_SUBDIR)
|
||||||
SET(LIBSHM_INSTALL_LIB_SUBDIR "lib" CACHE PATH "libshm install library directory")
|
SET(LIBSHM_INSTALL_LIB_SUBDIR "lib" CACHE PATH "libshm install library directory")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
# Flags
|
# Flags
|
||||||
# When using MSVC
|
# When using MSVC
|
||||||
IF(MSVC)
|
if(MSVC)
|
||||||
# we want to respect the standard, and we are bored of those **** .
|
# we want to respect the standard, and we are bored of those **** .
|
||||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE=1)
|
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE=1)
|
||||||
ENDIF(MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
IF (CMAKE_VERSION VERSION_LESS "3.1")
|
if(CMAKE_VERSION VERSION_LESS "3.1")
|
||||||
SET(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")
|
SET(CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")
|
||||||
ELSE ()
|
else()
|
||||||
SET(CMAKE_CXX_STANDARD 14)
|
SET(CMAKE_CXX_STANDARD 14)
|
||||||
ENDIF ()
|
endif()
|
||||||
|
|
||||||
ADD_LIBRARY(shm SHARED core.cpp)
|
ADD_LIBRARY(shm SHARED core.cpp)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
IF(NOT LIBSHM_INSTALL_LIB_SUBDIR)
|
if(NOT LIBSHM_INSTALL_LIB_SUBDIR)
|
||||||
SET(LIBSHM_INSTALL_BIN_SUBDIR "bin" CACHE PATH "libshm install binary directory")
|
SET(LIBSHM_INSTALL_BIN_SUBDIR "bin" CACHE PATH "libshm install binary directory")
|
||||||
SET(LIBSHM_INSTALL_LIB_SUBDIR "lib" CACHE PATH "libshm install library directory")
|
SET(LIBSHM_INSTALL_LIB_SUBDIR "lib" CACHE PATH "libshm install library directory")
|
||||||
ENDIF()
|
endif()
|
||||||
|
|
||||||
ADD_LIBRARY(shm SHARED core.cpp)
|
ADD_LIBRARY(shm SHARED core.cpp)
|
||||||
|
|
||||||
@ -23,6 +23,6 @@ TARGET_LINK_LIBRARIES(shm torch c10)
|
|||||||
INSTALL(TARGETS shm DESTINATION "${LIBSHM_INSTALL_LIB_SUBDIR}")
|
INSTALL(TARGETS shm DESTINATION "${LIBSHM_INSTALL_LIB_SUBDIR}")
|
||||||
INSTALL(FILES libshm.h DESTINATION "include")
|
INSTALL(FILES libshm.h DESTINATION "include")
|
||||||
|
|
||||||
if (MSVC AND BUILD_SHARED_LIBS)
|
if(MSVC AND BUILD_SHARED_LIBS)
|
||||||
INSTALL(FILES $<TARGET_PDB_FILE:shm> DESTINATION "${LIBSHM_INSTALL_LIB_SUBDIR}" OPTIONAL)
|
INSTALL(FILES $<TARGET_PDB_FILE:shm> DESTINATION "${LIBSHM_INSTALL_LIB_SUBDIR}" OPTIONAL)
|
||||||
endif()
|
endif()
|
||||||
|
Reference in New Issue
Block a user