| 1 | Patch build files to also system libraries instead of bundled ones for the
|
| 2 | libraries not supported or working only by specifying USE_SYSTEM_LIBS. This
|
| 3 | includes using the clog, cpuinfo, fbgemm, foxi, fp16, fxdiv, googletest,
|
| 4 | httlib, ideep, miniz, nnpack, oneapi-dnnl, pocketfft, pthreadpool,
|
| 5 | qnnpack-pytorch, tensorpipe, valgrind and xnnpack packages.
|
| 6 |
|
| 7 | diff --git i/aten/src/ATen/CMakeLists.txt w/aten/src/ATen/CMakeLists.txt
|
| 8 | index a3e841ca22a..632274abe5c 100644
|
| 9 | |
| 10 | |
| 11 | @@ -638,9 +638,9 @@ if(AT_NNPACK_ENABLED)
|
| 12 | list(APPEND ATen_CPU_DEPENDENCY_LIBS nnpack) # cpuinfo is added below
|
| 13 | endif()
|
| 14 |
|
| 15 | -if(MKLDNN_FOUND)
|
| 16 | - list(APPEND ATen_CPU_DEPENDENCY_LIBS ${MKLDNN_LIBRARIES})
|
| 17 | -endif(MKLDNN_FOUND)
|
| 18 | +if(USE_MKLDNN)
|
| 19 | + list(APPEND ATen_CPU_DEPENDENCY_LIBS DNNL::dnnl)
|
| 20 | +endif(USE_MKLDNN)
|
| 21 |
|
| 22 | if(USE_MKLDNN_ACL)
|
| 23 | list(APPEND ATen_CPU_INCLUDE ${ACL_INCLUDE_DIRS})
|
| 24 | diff --git i/caffe2/CMakeLists.txt w/caffe2/CMakeLists.txt
|
| 25 | index 6cbaecc5d2e..339145fab63 100644
|
| 26 | |
| 27 | |
| 28 | @@ -91,9 +91,6 @@ if(NOT MSVC AND USE_XNNPACK)
|
| 29 | if(NOT TARGET fxdiv)
|
| 30 | set(FXDIV_BUILD_TESTS OFF CACHE BOOL "")
|
| 31 | set(FXDIV_BUILD_BENCHMARKS OFF CACHE BOOL "")
|
| 32 | - add_subdirectory(
|
| 33 | - "${FXDIV_SOURCE_DIR}"
|
| 34 | - "${CMAKE_BINARY_DIR}/FXdiv")
|
| 35 | endif()
|
| 36 | endif()
|
| 37 |
|
| 38 | @@ -1212,7 +1209,6 @@ if(USE_XPU)
|
| 39 | endif()
|
| 40 |
|
| 41 | if(NOT MSVC AND USE_XNNPACK)
|
| 42 | - TARGET_LINK_LIBRARIES(torch_cpu PRIVATE fxdiv)
|
| 43 | endif()
|
| 44 |
|
| 45 | # ==========================================================
|
| 46 | @@ -1332,8 +1328,8 @@ endif()
|
| 47 | target_include_directories(torch_cpu PRIVATE
|
| 48 | ${TORCH_ROOT}/third_party/cpp-httplib)
|
| 49 |
|
| 50 | -target_include_directories(torch_cpu PRIVATE
|
| 51 | - ${TORCH_ROOT}/third_party/nlohmann/include)
|
| 52 | +find_package(httplib REQUIRED)
|
| 53 | +target_link_libraries(torch_cpu PUBLIC httplib::httplib)
|
| 54 |
|
| 55 | install(DIRECTORY
|
| 56 | "${TORCH_SRC_DIR}/csrc"
|
| 57 | @@ -1552,6 +1548,7 @@ target_link_libraries(torch_cpu PUBLIC c10)
|
| 58 | target_link_libraries(torch_cpu PUBLIC ${Caffe2_PUBLIC_DEPENDENCY_LIBS})
|
| 59 | target_link_libraries(torch_cpu PRIVATE ${Caffe2_DEPENDENCY_LIBS})
|
| 60 | target_link_libraries(torch_cpu PRIVATE ${Caffe2_DEPENDENCY_WHOLE_LINK_LIBS})
|
| 61 | +target_link_libraries(torch_cpu PRIVATE miniz clog)
|
| 62 | if(USE_MPI)
|
| 63 | target_link_libraries(torch_cpu PRIVATE MPI::MPI_CXX)
|
| 64 | endif()
|
| 65 | @@ -1819,7 +1816,7 @@ if(BUILD_MOBILE_TEST)
|
| 66 | foreach(test_src ${ATen_MOBILE_TEST_SRCS})
|
| 67 | get_filename_component(test_name ${test_src} NAME_WE)
|
| 68 | add_executable(${test_name} "${test_src}")
|
| 69 | - target_link_libraries(${test_name} torch_library gtest_main)
|
| 70 | + target_link_libraries(${test_name} torch_library gtest_main gtest)
|
| 71 | target_include_directories(${test_name} PRIVATE $<INSTALL_INTERFACE:include>)
|
| 72 | target_include_directories(${test_name} PRIVATE $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
|
| 73 | target_include_directories(${test_name} PRIVATE ${ATen_CPU_INCLUDE})
|
| 74 | @@ -1840,7 +1837,7 @@ if(BUILD_TEST)
|
| 75 | if(NOT MSVC)
|
| 76 | add_executable(${test_name}_${CPU_CAPABILITY} "${test_src}" ../aten/src/ATen/native/quantized/AffineQuantizerBase.cpp)
|
| 77 | # TODO: Get rid of c10 dependency (which is only needed for the implementation of AT_ERROR)
|
| 78 | - target_link_libraries(${test_name}_${CPU_CAPABILITY} c10 sleef gtest_main nlohmann)
|
| 79 | + target_link_libraries(${test_name}_${CPU_CAPABILITY} c10 sleef gtest_main gtest nlohmann)
|
| 80 | if(USE_FBGEMM)
|
| 81 | target_link_libraries(${test_name}_${CPU_CAPABILITY} fbgemm)
|
| 82 | endif()
|
| 83 | @@ -1860,7 +1857,7 @@ if(BUILD_TEST)
|
| 84 | endif()
|
| 85 | else()
|
| 86 | add_executable(${test_name}_${CPU_CAPABILITY} "${test_src}")
|
| 87 | - target_link_libraries(${test_name}_${CPU_CAPABILITY} torch_library sleef gtest_main)
|
| 88 | + target_link_libraries(${test_name}_${CPU_CAPABILITY} torch_library sleef gtest_main gtest)
|
| 89 | endif()
|
| 90 | target_include_directories(${test_name}_${CPU_CAPABILITY} PRIVATE $<INSTALL_INTERFACE:include>)
|
| 91 | target_include_directories(${test_name}_${CPU_CAPABILITY} PRIVATE $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
|
| 92 | @@ -1901,7 +1898,7 @@ if(BUILD_TEST)
|
| 93 | add_executable(${test_name} "${test_src}")
|
| 94 | find_library(metal NAMES Metal)
|
| 95 | find_library(foundation NAMES Foundation)
|
| 96 | - target_link_libraries(${test_name} torch_library gtest_main ${metal} ${foundation})
|
| 97 | + target_link_libraries(${test_name} torch_library gtest_main gtest ${metal} ${foundation})
|
| 98 | target_include_directories(${test_name} PRIVATE $<INSTALL_INTERFACE:include>)
|
| 99 | target_include_directories(${test_name} PRIVATE $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
|
| 100 | target_include_directories(${test_name} PRIVATE ${Caffe2_CPU_INCLUDE})
|
| 101 | @@ -1921,7 +1918,7 @@ if(BUILD_TEST)
|
| 102 | foreach(test_src ${Caffe2_GPU_TEST_SRCS})
|
| 103 | get_filename_component(test_name ${test_src} NAME_WE)
|
| 104 | add_executable(${test_name} "${test_src}")
|
| 105 | - target_link_libraries(${test_name} torch_library gtest_main)
|
| 106 | + target_link_libraries(${test_name} torch_library gtest_main gtest)
|
| 107 | if(USE_CUDNN AND ${test_name} MATCHES "cudnn")
|
| 108 | target_link_libraries(${test_name} torch::cudnn)
|
| 109 | endif()
|
| 110 | @@ -1944,7 +1941,7 @@ if(BUILD_TEST)
|
| 111 | get_filename_component(test_name ${test_src} NAME_WE)
|
| 112 | add_executable(${test_name} "${test_src}")
|
| 113 | torch_compile_options(${test_name})
|
| 114 | - target_link_libraries(${test_name} torch_library gtest_main)
|
| 115 | + target_link_libraries(${test_name} torch_library gtest_main gtest)
|
| 116 | target_include_directories(${test_name} PRIVATE $<INSTALL_INTERFACE:include>)
|
| 117 | target_include_directories(${test_name} PRIVATE ${Caffe2_CPU_INCLUDE})
|
| 118 | add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
|
| 119 | @@ -1959,7 +1956,7 @@ if(BUILD_TEST)
|
| 120 | foreach(test_src ${Caffe2_VULKAN_TEST_SRCS})
|
| 121 | get_filename_component(test_name ${test_src} NAME_WE)
|
| 122 | add_executable(${test_name} "${test_src}")
|
| 123 | - target_link_libraries(${test_name} torch_library gtest_main)
|
| 124 | + target_link_libraries(${test_name} torch_library gtest_main gtest)
|
| 125 | target_include_directories(${test_name} PRIVATE $<INSTALL_INTERFACE:include>)
|
| 126 | target_include_directories(${test_name} PRIVATE ${Caffe2_CPU_INCLUDE})
|
| 127 | add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
|
| 128 | @@ -1991,7 +1988,7 @@ if(BUILD_TEST)
|
| 129 | if(test_src MATCHES "^.*\.hip$")
|
| 130 | set_target_properties(${test_name} PROPERTIES LINKER_LANGUAGE CXX)
|
| 131 | endif()
|
| 132 | - target_link_libraries(${test_name} torch_library gtest_main)
|
| 133 | + target_link_libraries(${test_name} torch_library gtest_main gtest)
|
| 134 | target_include_directories(${test_name} PRIVATE $<INSTALL_INTERFACE:include>)
|
| 135 | target_include_directories(${test_name} PRIVATE ${Caffe2_CPU_INCLUDE} ${Caffe2_HIP_INCLUDE})
|
| 136 | target_compile_options(${test_name} PRIVATE ${HIP_CXX_FLAGS})
|
| 137 | diff --git i/caffe2/serialize/CMakeLists.txt w/caffe2/serialize/CMakeLists.txt
|
| 138 | index ebbff0f292a..dcded25908e 100644
|
| 139 | |
| 140 | |
| 141 | @@ -2,7 +2,6 @@ file(GLOB tmp *_test.cc)
|
| 142 |
|
| 143 | set(Caffe2_CPU_TEST_SRCS ${Caffe2_CPU_TEST_SRCS} ${tmp})
|
| 144 | list(APPEND Caffe2_CPU_SRCS
|
| 145 | - ${PROJECT_SOURCE_DIR}/third_party/miniz-3.0.2/miniz.c
|
| 146 | ${CMAKE_CURRENT_SOURCE_DIR}/inline_container.cc
|
| 147 | ${CMAKE_CURRENT_SOURCE_DIR}/istream_adapter.cc
|
| 148 | ${CMAKE_CURRENT_SOURCE_DIR}/file_adapter.cc
|
| 149 | diff --git i/cmake/Dependencies.cmake w/cmake/Dependencies.cmake
|
| 150 | index 903c212de81..a6972b40370 100644
|
| 151 | |
| 152 | |
| 153 | @@ -307,7 +307,7 @@ endif()
|
| 154 | # --- [ PocketFFT
|
| 155 | set(AT_POCKETFFT_ENABLED 0)
|
| 156 | if(NOT AT_MKL_ENABLED)
|
| 157 | - set(POCKETFFT_INCLUDE_DIR "${Torch_SOURCE_DIR}/third_party/pocketfft/")
|
| 158 | + set(POCKETFFT_INCLUDE_DIR "#POCKETFFT_INCLUDE_DIR")
|
| 159 | if(NOT EXISTS "${POCKETFFT_INCLUDE_DIR}")
|
| 160 | message(FATAL_ERROR "pocketfft directory not found, expected ${POCKETFFT_INCLUDE_DIR}")
|
| 161 | elseif(NOT EXISTS "${POCKETFFT_INCLUDE_DIR}/pocketfft_hdronly.h")
|
| 162 | @@ -491,15 +491,6 @@ if(USE_PYTORCH_QNNPACK)
|
| 163 | set(PYTORCH_QNNPACK_BUILD_TESTS OFF CACHE BOOL "")
|
| 164 | set(PYTORCH_QNNPACK_BUILD_BENCHMARKS OFF CACHE BOOL "")
|
| 165 | set(PYTORCH_QNNPACK_LIBRARY_TYPE "static" CACHE STRING "")
|
| 166 | - add_subdirectory(
|
| 167 | - "${PYTORCH_QNNPACK_SOURCE_DIR}"
|
| 168 | - "${CONFU_DEPENDENCIES_BINARY_DIR}/pytorch_qnnpack")
|
| 169 | - # We build static versions of QNNPACK and pthreadpool but link
|
| 170 | - # them into a shared library for Caffe2, so they need PIC.
|
| 171 | - set_property(TARGET pytorch_qnnpack PROPERTY POSITION_INDEPENDENT_CODE ON)
|
| 172 | - set_property(TARGET cpuinfo PROPERTY POSITION_INDEPENDENT_CODE ON)
|
| 173 | - # QNNPACK depends on gemmlowp headers
|
| 174 | - target_include_directories(pytorch_qnnpack PRIVATE "${CAFFE2_THIRD_PARTY_ROOT}/gemmlowp")
|
| 175 | endif()
|
| 176 |
|
| 177 | list(APPEND Caffe2_DEPENDENCY_LIBS pytorch_qnnpack)
|
| 178 | @@ -595,16 +586,15 @@ if(USE_XNNPACK AND NOT USE_SYSTEM_XNNPACK)
|
| 179 | list(APPEND Caffe2_DEPENDENCY_LIBS XNNPACK microkernels-prod)
|
| 180 | elseif(NOT TARGET XNNPACK AND USE_SYSTEM_XNNPACK)
|
| 181 | add_library(XNNPACK SHARED IMPORTED)
|
| 182 | - add_library(microkernels-prod SHARED IMPORTED)
|
| 183 | + add_library(microkernels-prod INTERFACE IMPORTED)
|
| 184 | find_library(XNNPACK_LIBRARY XNNPACK)
|
| 185 | - find_library(microkernels-prod_LIBRARY microkernels-prod)
|
| 186 | set_property(TARGET XNNPACK PROPERTY IMPORTED_LOCATION "${XNNPACK_LIBRARY}")
|
| 187 | - set_property(TARGET microkernels-prod PROPERTY IMPORTED_LOCATION "${microkernels-prod_LIBRARY}")
|
| 188 | - if(NOT XNNPACK_LIBRARY OR NOT microkernels-prod_LIBRARY)
|
| 189 | + set_property(TARGET microkernels-prod PROPERTY INTERFACE_LINK_LIBRARIES XNNPACK)
|
| 190 | + if(NOT XNNPACK_LIBRARY)
|
| 191 | message(FATAL_ERROR "Cannot find XNNPACK")
|
| 192 | endif()
|
| 193 | message("-- Found XNNPACK: ${XNNPACK_LIBRARY}")
|
| 194 | - list(APPEND Caffe2_DEPENDENCY_LIBS XNNPACK microkernels-prod)
|
| 195 | + list(APPEND Caffe2_DEPENDENCY_LIBS XNNPACK)
|
| 196 | endif()
|
| 197 |
|
| 198 | # ---[ Vulkan deps
|
| 199 | @@ -658,9 +648,6 @@ if(BUILD_TEST OR BUILD_MOBILE_BENCHMARK OR BUILD_MOBILE_TEST)
|
| 200 | set(INSTALL_GTEST OFF CACHE BOOL "Install gtest." FORCE)
|
| 201 | set(BUILD_GMOCK ON CACHE BOOL "Build gmock." FORCE)
|
| 202 |
|
| 203 | - add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest)
|
| 204 | - include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googletest/include)
|
| 205 | - include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googlemock/include)
|
| 206 |
|
| 207 | # We will not need to test benchmark lib itself.
|
| 208 | set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable benchmark testing as we don't need it.")
|
| 209 | @@ -692,16 +679,22 @@ if(USE_FBGEMM)
|
| 210 | set(FBGEMM_BUILD_TESTS OFF CACHE BOOL "")
|
| 211 | set(FBGEMM_BUILD_BENCHMARKS OFF CACHE BOOL "")
|
| 212 | set(FBGEMM_LIBRARY_TYPE "static" CACHE STRING "")
|
| 213 | - add_subdirectory("${FBGEMM_SOURCE_DIR}")
|
| 214 | -
|
| 215 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
| 216 | - target_compile_options_if_supported(asmjit -Wno-extra-semi)
|
| 217 | - target_compile_options_if_supported(fbgemm -Wno-extra-semi)
|
| 218 | + if(TARGET asmjit)
|
| 219 | + target_compile_options_if_supported(asmjit -Wno-extra-semi)
|
| 220 | + endif()
|
| 221 | + if(TARGET fbgemm)
|
| 222 | + target_compile_options_if_supported(fbgemm -Wno-extra-semi)
|
| 223 | + endif()
|
| 224 | + endif()
|
| 225 | + if(TARGET asmjit)
|
| 226 | + target_compile_options_if_supported(asmjit -Wno-unused-but-set-variable)
|
| 227 | + target_compile_options_if_supported(asmjit -Wno-unused-variable)
|
| 228 | endif()
|
| 229 | - target_compile_options_if_supported(asmjit -Wno-unused-but-set-variable)
|
| 230 | - target_compile_options_if_supported(asmjit -Wno-unused-variable)
|
| 231 | endif()
|
| 232 | if(USE_FBGEMM)
|
| 233 | + # Don't set compile definitions on system fbgemm
|
| 234 | + # target_compile_definitions(fbgemm PUBLIC DISABLE_FBGEMM_AUTOVEC)
|
| 235 | list(APPEND Caffe2_DEPENDENCY_LIBS fbgemm)
|
| 236 | endif()
|
| 237 | endif()
|
| 238 | @@ -772,7 +765,7 @@ if(NOT TARGET fp16 AND NOT USE_SYSTEM_FP16)
|
| 239 | "${CONFU_DEPENDENCIES_BINARY_DIR}/FP16")
|
| 240 | endif()
|
| 241 | elseif(NOT TARGET fp16 AND USE_SYSTEM_FP16)
|
| 242 | - add_library(fp16 STATIC "/usr/include/fp16.h")
|
| 243 | + add_library(fp16 STATIC "#FP16_INCLUDE_DIR")
|
| 244 | set_target_properties(fp16 PROPERTIES LINKER_LANGUAGE C)
|
| 245 | endif()
|
| 246 | list(APPEND Caffe2_DEPENDENCY_LIBS fp16)
|
| 247 | @@ -1165,10 +1158,11 @@ if(USE_DISTRIBUTED AND USE_TENSORPIPE)
|
| 248 |
|
| 249 | # Tensorpipe uses cuda_add_library
|
| 250 | torch_update_find_cuda_flags()
|
| 251 | - add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/tensorpipe)
|
| 252 | # Suppress warning to unblock libnop compilation by clang-17
|
| 253 | # See https://github.com/pytorch/pytorch/issues/151316
|
| 254 | - target_compile_options_if_supported(tensorpipe -Wno-missing-template-arg-list-after-template-kw)
|
| 255 | + if(TARGET tensorpipe)
|
| 256 | + target_compile_options_if_supported(tensorpipe -Wno-missing-template-arg-list-after-template-kw)
|
| 257 | + endif()
|
| 258 | # Workaround for relocation truncated to fit: R_AARCH64_CALL26 against symbol __aarch64_swp4_relax'
|
| 259 | # When compiling for ARMv8.0, build uv with embedded atomics, which are slightly slower
|
| 260 | # But are used only once during shutdown
|
| 261 | @@ -1350,7 +1344,7 @@ if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
|
| 262 | endif()
|
| 263 | set_property(TARGET onnx_proto PROPERTY IMPORTED_LOCATION ${ONNX_PROTO_LIBRARY})
|
| 264 | message("-- Found onnx: ${ONNX_LIBRARY} ${ONNX_PROTO_LIBRARY}")
|
| 265 | - list(APPEND Caffe2_DEPENDENCY_LIBS onnx_proto onnx)
|
| 266 | + list(APPEND Caffe2_DEPENDENCY_LIBS onnx_proto onnx onnx_optimizer)
|
| 267 | endif()
|
| 268 | # Recover the build shared libs option.
|
| 269 | set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS})
|
| 270 | @@ -1513,9 +1507,8 @@ if(NOT INTERN_BUILD_MOBILE)
|
| 271 | endif()
|
| 272 | if(USE_MKLDNN)
|
| 273 | include(${CMAKE_CURRENT_LIST_DIR}/public/mkldnn.cmake)
|
| 274 | - if(MKLDNN_FOUND)
|
| 275 | + if(DNNL_FOUND)
|
| 276 | set(AT_MKLDNN_ENABLED 1)
|
| 277 | - include_directories(AFTER SYSTEM ${MKLDNN_INCLUDE_DIR})
|
| 278 | else()
|
| 279 | message(WARNING "MKLDNN could not be found.")
|
| 280 | caffe2_update_option(USE_MKLDNN OFF)
|
| 281 | @@ -1590,7 +1583,7 @@ endif()
|
| 282 | set(FMT_INSTALL ON)
|
| 283 | set(TEMP_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
|
| 284 | set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE)
|
| 285 | -add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/fmt)
|
| 286 | +find_package(fmt)
|
| 287 |
|
| 288 | # Disable compiler feature checks for `fmt`.
|
| 289 | #
|
| 290 | @@ -1599,7 +1592,6 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/fmt)
|
| 291 | # CMAKE_CXX_FLAGS in ways that break feature checks. Since we already know
|
| 292 | # `fmt` is compatible with a superset of the compilers that PyTorch is, it
|
| 293 | # shouldn't be too bad to just disable the checks.
|
| 294 | -set_target_properties(fmt-header-only PROPERTIES INTERFACE_COMPILE_FEATURES "")
|
| 295 |
|
| 296 | list(APPEND Caffe2_DEPENDENCY_LIBS fmt::fmt-header-only)
|
| 297 | set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
|
| 298 | @@ -1695,4 +1687,5 @@ include_directories(nlohmann SYSTEM INTERFACE ${PROJECT_SOURCE_DIR}/third_party/
|
| 299 |
|
| 300 | # Include moodycamel
|
| 301 | add_library(moodycamel INTERFACE IMPORTED)
|
| 302 | -include_directories(moodycamel SYSTEM INTERFACE ${PROJECT_SOURCE_DIR}/third_party/concurrentqueue)
|
| 303 | +# Use system concurrentqueue - it's a header-only library
|
| 304 | +include_directories(SYSTEM #CONCURRENTQUEUE_INCLUDE_DIR)
|
| 305 | diff --git i/cmake/External/nnpack.cmake w/cmake/External/nnpack.cmake
|
| 306 | index 8a4a310d629..f413d2e6181 100644
|
| 307 | |
| 308 | |
| 309 | @@ -40,7 +40,7 @@ endif()
|
| 310 | # (3) Android, iOS, Linux, macOS - supported
|
| 311 | ##############################################################################
|
| 312 |
|
| 313 | -if(ANDROID OR IOS OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
| 314 | +if(FALSE)
|
| 315 | message(STATUS "Brace yourself, we are building NNPACK")
|
| 316 | set(CAFFE2_THIRD_PARTY_ROOT ${PROJECT_SOURCE_DIR}/third_party)
|
| 317 |
|
| 318 | @@ -94,6 +94,5 @@ endif()
|
| 319 | # (4) Catch-all: not supported.
|
| 320 | ##############################################################################
|
| 321 |
|
| 322 | -message(WARNING "Unknown platform - I don't know how to build NNPACK. "
|
| 323 | - "See cmake/External/nnpack.cmake for details.")
|
| 324 | -set(USE_NNPACK OFF)
|
| 325 | +set(NNPACK_FOUND TRUE)
|
| 326 | +set(USE_NNPACK ON)
|
| 327 | diff --git i/cmake/public/mkldnn.cmake w/cmake/public/mkldnn.cmake
|
| 328 | index 87935625f9b..9f8fa3df81f 100644
|
| 329 | |
| 330 | |
| 331 | @@ -4,7 +4,7 @@ if(CPU_AARCH64)
|
| 332 | include(${CMAKE_CURRENT_LIST_DIR}/ComputeLibrary.cmake)
|
| 333 | endif()
|
| 334 |
|
| 335 | -find_package(MKLDNN QUIET)
|
| 336 | +find_package(DNNL REQUIRED)
|
| 337 |
|
| 338 | if(NOT TARGET caffe2::mkldnn)
|
| 339 | add_library(caffe2::mkldnn INTERFACE IMPORTED)
|
| 340 | @@ -15,4 +15,4 @@ set_property(
|
| 341 | ${MKLDNN_INCLUDE_DIR})
|
| 342 | set_property(
|
| 343 | TARGET caffe2::mkldnn PROPERTY INTERFACE_LINK_LIBRARIES
|
| 344 | - ${MKLDNN_LIBRARIES})
|
| 345 | + DNNL::dnnl)
|
| 346 | diff --git i/setup.py w/setup.py
|
| 347 | index da38ba785f1..2d41bc13107 100644
|
| 348 | |
| 349 | |
| 350 | @@ -1060,13 +1060,9 @@ def build_deps() -> None:
|
| 351 | # Windows has very poor support for them.
|
| 352 | sym_files = [
|
| 353 | CWD / "tools/shared/_utils_internal.py",
|
| 354 | - CWD / "torch/utils/benchmark/utils/valgrind_wrapper/callgrind.h",
|
| 355 | - CWD / "torch/utils/benchmark/utils/valgrind_wrapper/valgrind.h",
|
| 356 | ]
|
| 357 | orig_files = [
|
| 358 | CWD / "torch/_utils_internal.py",
|
| 359 | - CWD / "third_party/valgrind-headers/callgrind.h",
|
| 360 | - CWD / "third_party/valgrind-headers/valgrind.h",
|
| 361 | ]
|
| 362 | for sym_file, orig_file in zip(sym_files, orig_files):
|
| 363 | same = False
|
| 364 | diff --git i/test/cpp/aoti_abi_check/CMakeLists.txt w/test/cpp/aoti_abi_check/CMakeLists.txt
|
| 365 | index 4146819e2f1..227413712cd 100644
|
| 366 | |
| 367 | |
| 368 | @@ -44,7 +44,7 @@ target_compile_definitions(test_aoti_abi_check PRIVATE USE_GTEST)
|
| 369 |
|
| 370 | # WARNING: DO NOT LINK torch!!!
|
| 371 | # The purpose is to check if the used aten/c10 headers are written in a header-only way
|
| 372 | -target_link_libraries(test_aoti_abi_check PRIVATE gtest_main sleef)
|
| 373 | +target_link_libraries(test_aoti_abi_check PRIVATE gtest_main gtest sleef)
|
| 374 | target_include_directories(test_aoti_abi_check PRIVATE ${ATen_CPU_INCLUDE})
|
| 375 | if(NOT USE_SYSTEM_SLEEF)
|
| 376 | target_include_directories(test_aoti_abi_check PRIVATE ${CMAKE_BINARY_DIR}/include)
|
| 377 | @@ -66,7 +66,7 @@ foreach(test_src ${AOTI_ABI_CHECK_VEC_TEST_SRCS})
|
| 378 | separate_arguments(FLAGS UNIX_COMMAND "${FLAGS}")
|
| 379 | add_executable(${test_name}_${CPU_CAPABILITY} "${test_src}")
|
| 380 |
|
| 381 | - target_link_libraries(${test_name}_${CPU_CAPABILITY} PRIVATE gtest_main sleef)
|
| 382 | + target_link_libraries(${test_name}_${CPU_CAPABILITY} PRIVATE gtest_main gtest sleef)
|
| 383 | target_include_directories(${test_name}_${CPU_CAPABILITY} PRIVATE ${ATen_CPU_INCLUDE})
|
| 384 | if(NOT USE_SYSTEM_SLEEF)
|
| 385 | target_include_directories(${test_name}_${CPU_CAPABILITY} PRIVATE ${CMAKE_BINARY_DIR}/include)
|
| 386 | diff --git i/test/cpp/aoti_inference/CMakeLists.txt w/test/cpp/aoti_inference/CMakeLists.txt
|
| 387 | index 79e08471568..39002e7ac69 100644
|
| 388 | |
| 389 | |
| 390 | @@ -29,7 +29,7 @@ target_compile_definitions(test_aoti_inference PRIVATE USE_GTEST)
|
| 391 |
|
| 392 | target_link_libraries(test_aoti_inference PRIVATE
|
| 393 | torch
|
| 394 | - gtest_main
|
| 395 | + gtest_main gtest
|
| 396 | -Wl,--no-as-needed aoti_custom_class
|
| 397 | )
|
| 398 |
|
| 399 | diff --git i/test/cpp/api/CMakeLists.txt w/test/cpp/api/CMakeLists.txt
|
| 400 | index a92832a4d04..6f8ec13526c 100644
|
| 401 | |
| 402 | |
| 403 | @@ -50,7 +50,7 @@ endif()
|
| 404 |
|
| 405 | add_executable(test_api ${TORCH_API_TEST_SOURCES})
|
| 406 | target_include_directories(test_api PRIVATE ${ATen_CPU_INCLUDE})
|
| 407 | -target_link_libraries(test_api PRIVATE torch gtest_main gmock)
|
| 408 | +target_link_libraries(test_api PRIVATE torch gtest_main gtest gmock)
|
| 409 |
|
| 410 | if(USE_CUDA)
|
| 411 | target_compile_definitions(test_api PRIVATE "USE_CUDA")
|
| 412 | diff --git i/test/cpp/c10d/CMakeLists.txt w/test/cpp/c10d/CMakeLists.txt
|
| 413 | index 285a5dd2a73..6cb87fcbdd5 100644
|
| 414 | |
| 415 | |
| 416 | @@ -32,17 +32,17 @@ function(c10d_add_test test_src)
|
| 417 | endif()
|
| 418 | endfunction()
|
| 419 |
|
| 420 | -c10d_add_test(BackoffTest.cpp LINK_LIBRARIES torch_cpu gtest_main INSTALL_TEST OFF)
|
| 421 | -c10d_add_test(FileStoreTest.cpp LINK_LIBRARIES torch_cpu gtest_main INSTALL_TEST ${INSTALL_TEST})
|
| 422 | -c10d_add_test(TCPStoreTest.cpp LINK_LIBRARIES torch_cpu gtest_main INSTALL_TEST ${INSTALL_TEST})
|
| 423 | +c10d_add_test(BackoffTest.cpp LINK_LIBRARIES torch_cpu gtest_main gtest INSTALL_TEST OFF)
|
| 424 | +c10d_add_test(FileStoreTest.cpp LINK_LIBRARIES torch_cpu gtest_main gtest INSTALL_TEST ${INSTALL_TEST})
|
| 425 | +c10d_add_test(TCPStoreTest.cpp LINK_LIBRARIES torch_cpu gtest_main gtest INSTALL_TEST ${INSTALL_TEST})
|
| 426 | if(NOT WIN32)
|
| 427 | - c10d_add_test(HashStoreTest.cpp LINK_LIBRARIES torch_cpu gtest_main INSTALL_TEST ${INSTALL_TEST})
|
| 428 | + c10d_add_test(HashStoreTest.cpp LINK_LIBRARIES torch_cpu gtest_main gtest INSTALL_TEST ${INSTALL_TEST})
|
| 429 | endif()
|
| 430 |
|
| 431 | if(USE_CUDA)
|
| 432 | if(USE_GLOO AND USE_C10D_GLOO)
|
| 433 | - c10d_add_test(ProcessGroupGlooTest.cpp LINK_LIBRARIES torch_cpu c10d_cuda_test gtest_main INSTALL_TEST ${INSTALL_TEST})
|
| 434 | - c10d_add_test(ProcessGroupGlooAsyncTest.cpp LINK_LIBRARIES torch_cpu c10d_cuda_test gtest_main INSTALL_TEST ${INSTALL_TEST})
|
| 435 | + c10d_add_test(ProcessGroupGlooTest.cpp LINK_LIBRARIES torch_cpu c10d_cuda_test gtest_main gtest gloo INSTALL_TEST ${INSTALL_TEST})
|
| 436 | + c10d_add_test(ProcessGroupGlooAsyncTest.cpp LINK_LIBRARIES torch_cpu c10d_cuda_test gtest_main gtest gloo INSTALL_TEST ${INSTALL_TEST})
|
| 437 | endif()
|
| 438 | if(USE_NCCL AND USE_C10D_NCCL)
|
| 439 | # NCCL is a private dependency of libtorch, but the tests include some
|
| 440 | @@ -51,10 +51,10 @@ if(USE_CUDA)
|
| 441 | # a private dependency of the tests as well.
|
| 442 | c10d_add_test(
|
| 443 | ProcessGroupNCCLTest.cpp
|
| 444 | - LINK_LIBRARIES torch_cpu c10d_cuda_test gtest_main __caffe2_nccl INSTALL_TEST ${INSTALL_TEST})
|
| 445 | + LINK_LIBRARIES torch_cpu c10d_cuda_test gtest_main gtest __caffe2_nccl INSTALL_TEST ${INSTALL_TEST})
|
| 446 | c10d_add_test(
|
| 447 | ProcessGroupNCCLErrorsTest.cpp
|
| 448 | - LINK_LIBRARIES torch_cpu c10d_cuda_test gtest_main __caffe2_nccl INSTALL_TEST ${INSTALL_TEST})
|
| 449 | + LINK_LIBRARIES torch_cpu c10d_cuda_test gtest_main gtest __caffe2_nccl INSTALL_TEST ${INSTALL_TEST})
|
| 450 | if(INSTALL_TEST)
|
| 451 | install(TARGETS c10d_cuda_test DESTINATION lib)
|
| 452 | endif()
|
| 453 | @@ -66,14 +66,14 @@ if(USE_CUDA)
|
| 454 | # a private dependency of the tests as well.
|
| 455 | c10d_add_test(
|
| 456 | ProcessGroupUCCTest.cpp
|
| 457 | - LINK_LIBRARIES torch_cpu c10d_cuda_test gtest_main __caffe2_ucc INSTALL_TEST ${INSTALL_TEST})
|
| 458 | + LINK_LIBRARIES torch_cpu c10d_cuda_test gtest_main gtest __caffe2_ucc INSTALL_TEST ${INSTALL_TEST})
|
| 459 | if(INSTALL_TEST)
|
| 460 | install(TARGETS c10d_cuda_test DESTINATION lib)
|
| 461 | endif()
|
| 462 | endif()
|
| 463 | else()
|
| 464 | if(USE_GLOO AND USE_C10D_GLOO)
|
| 465 | - c10d_add_test(ProcessGroupGlooTest.cpp LINK_LIBRARIES torch_cpu gtest_main INSTALL_TEST OFF)
|
| 466 | + c10d_add_test(ProcessGroupGlooTest.cpp LINK_LIBRARIES torch_cpu gtest_main gtest gloo INSTALL_TEST OFF)
|
| 467 | endif()
|
| 468 | endif()
|
| 469 |
|
| 470 | diff --git i/test/cpp/dist_autograd/CMakeLists.txt w/test/cpp/dist_autograd/CMakeLists.txt
|
| 471 | index 14fd7f7ae9a..9564d1270cb 100644
|
| 472 | |
| 473 | |
| 474 | @@ -7,7 +7,7 @@ if(USE_DISTRIBUTED AND NOT WIN32)
|
| 475 |
|
| 476 | add_executable(test_dist_autograd ${DIST_AUTOGRAD_TEST_SOURCES})
|
| 477 | target_include_directories(test_dist_autograd PRIVATE ${ATen_CPU_INCLUDE})
|
| 478 | - target_link_libraries(test_dist_autograd PRIVATE torch gtest_main)
|
| 479 | + target_link_libraries(test_dist_autograd PRIVATE torch gtest_main gtest)
|
| 480 |
|
| 481 | if(USE_CUDA)
|
| 482 | target_compile_definitions(test_dist_autograd PRIVATE "USE_CUDA")
|
| 483 | diff --git i/test/cpp/jit/CMakeLists.txt w/test/cpp/jit/CMakeLists.txt
|
| 484 | index 0b2a06b53c9..9c04aec99a8 100644
|
| 485 | |
| 486 | |
| 487 | @@ -126,7 +126,7 @@ if(USE_MKLDNN)
|
| 488 | target_link_libraries(test_jit PRIVATE caffe2::mkldnn)
|
| 489 | endif()
|
| 490 |
|
| 491 | -set(JIT_TEST_DEPENDENCIES torch gtest_main jitbackend_test backend_with_compiler gmock)
|
| 492 | +set(JIT_TEST_DEPENDENCIES torch gtest_main gtest jitbackend_test backend_with_compiler gmock)
|
| 493 |
|
| 494 | if(MSVC)
|
| 495 | list(APPEND JIT_TEST_DEPENDENCIES onnx_library)
|
| 496 | diff --git i/test/cpp/lazy/CMakeLists.txt w/test/cpp/lazy/CMakeLists.txt
|
| 497 | index 8bcd7ade611..131d0ae464c 100644
|
| 498 | |
| 499 | |
| 500 | @@ -28,7 +28,7 @@ add_executable(test_lazy
|
| 501 | # TODO temporary until we can delete the old gtest polyfills.
|
| 502 | target_compile_definitions(test_lazy PRIVATE USE_GTEST)
|
| 503 |
|
| 504 | -set(LAZY_TEST_DEPENDENCIES torch gtest_main)
|
| 505 | +set(LAZY_TEST_DEPENDENCIES torch gtest_main gtest)
|
| 506 |
|
| 507 | target_link_libraries(test_lazy PRIVATE ${LAZY_TEST_DEPENDENCIES})
|
| 508 | target_include_directories(test_lazy PRIVATE ${ATen_CPU_INCLUDE})
|
| 509 | diff --git i/test/cpp/lite_interpreter_runtime/CMakeLists.txt w/test/cpp/lite_interpreter_runtime/CMakeLists.txt
|
| 510 | index 5c27dd84f7c..27f7afdaeb4 100644
|
| 511 | |
| 512 | |
| 513 | @@ -21,7 +21,7 @@ target_include_directories(
|
| 514 | ${ATen_CPU_INCLUDE}
|
| 515 | )
|
| 516 |
|
| 517 | -target_link_libraries(test_lite_interpreter_runtime PRIVATE torch gtest_main backend_with_compiler_runtime)
|
| 518 | +target_link_libraries(test_lite_interpreter_runtime PRIVATE torch gtest_main gtest backend_with_compiler_runtime)
|
| 519 |
|
| 520 | if(LINUX)
|
| 521 | target_link_libraries(test_lite_interpreter_runtime PRIVATE "-Wl,--no-as-needed,$<TARGET_FILE:backend_with_compiler_runtime>,--as-needed")
|
| 522 | diff --git i/test/cpp/nativert/CMakeLists.txt w/test/cpp/nativert/CMakeLists.txt
|
| 523 | index 77636a2d109..04921418338 100644
|
| 524 | |
| 525 | |
| 526 | @@ -65,7 +65,7 @@ endif()
|
| 527 | # TODO temporary until we can delete the old gtest polyfills.
|
| 528 | target_compile_definitions(test_nativert PRIVATE USE_GTEST)
|
| 529 |
|
| 530 | -set(NATIVERT_TEST_DEPENDENCIES torch gtest_main)
|
| 531 | +set(NATIVERT_TEST_DEPENDENCIES torch gtest_main gtest)
|
| 532 |
|
| 533 | target_link_libraries(test_nativert PRIVATE ${CMAKE_DL_LIBS})
|
| 534 | target_link_libraries(test_nativert PRIVATE ${NATIVERT_TEST_DEPENDENCIES})
|
| 535 | diff --git i/test/cpp/rpc/CMakeLists.txt w/test/cpp/rpc/CMakeLists.txt
|
| 536 | index 454c54a0187..301319bbe71 100644
|
| 537 | |
| 538 | |
| 539 | @@ -5,7 +5,7 @@ set(TORCH_RPC_TEST_SOURCES
|
| 540 | ${TORCH_RPC_TEST_DIR}/test_wire_serialization.cpp
|
| 541 | )
|
| 542 | set(TORCH_RPC_TEST_DEPENDENCY_LIBS
|
| 543 | - torch gtest_main
|
| 544 | + torch gtest_main gtest
|
| 545 | )
|
| 546 |
|
| 547 | if(USE_GLOO)
|
| 548 | diff --git i/test/inductor/cpp/CMakeLists.txt w/test/inductor/cpp/CMakeLists.txt
|
| 549 | index 78a1ad8c2fd..e350270bf40 100644
|
| 550 | |
| 551 | |
| 552 | @@ -43,5 +43,5 @@ FetchContent_MakeAvailable(googletest)
|
| 553 | # TODO(voz): This is a little assumptive of just this one test, rewrite with real dir includes
|
| 554 | include_directories(${ATEN_INCLUDE})
|
| 555 | add_executable(test_cpp_prefix test_cpp_prefix.cpp ../../torchinductor/codegen/cpp_prefix.h)
|
| 556 | -target_link_libraries(test_cpp_prefix gtest_main)
|
| 557 | +target_link_libraries(test_cpp_prefix gtest_main gtest)
|
| 558 | add_test(NAME test_cpp_prefix COMMAND test_cpp_prefix)
|
| 559 | diff --git i/test/mobile/lightweight_dispatch/CMakeLists.txt w/test/mobile/lightweight_dispatch/CMakeLists.txt
|
| 560 | index 2064cea0d58..4090578fd6c 100644
|
| 561 | |
| 562 | |
| 563 | @@ -12,7 +12,7 @@ target_include_directories(test_codegen_unboxing PRIVATE ${ATen_CPU_INCLUDE})
|
| 564 |
|
| 565 | target_compile_definitions(test_codegen_unboxing PRIVATE USE_GTEST)
|
| 566 |
|
| 567 | -set(TEST_UNBOXING_DEPENDENCIES torch gtest_main)
|
| 568 | +set(TEST_UNBOXING_DEPENDENCIES torch gtest_main gtest)
|
| 569 |
|
| 570 | target_link_libraries(test_codegen_unboxing PRIVATE
|
| 571 | ${TEST_UNBOXING_DEPENDENCIES}
|
| 572 | diff --git i/test/mobile/nnc/CMakeLists.txt w/test/mobile/nnc/CMakeLists.txt
|
| 573 | index d38f0a41e22..136526b9dcd 100644
|
| 574 | |
| 575 | |
| 576 | @@ -11,7 +11,7 @@ add_executable(test_mobile_nnc
|
| 577 | ${MOBILE_NNC_TEST_SRCS}
|
| 578 | )
|
| 579 |
|
| 580 | -target_link_libraries(test_mobile_nnc PRIVATE torch gtest_main)
|
| 581 | +target_link_libraries(test_mobile_nnc PRIVATE torch gtest_main gtest)
|
| 582 | target_include_directories(test_mobile_nnc PRIVATE ${ATen_CPU_INCLUDE})
|
| 583 | target_compile_definitions(test_mobile_nnc PRIVATE USE_GTEST)
|
| 584 |
|
| 585 | diff --git i/torch/CMakeLists.txt w/torch/CMakeLists.txt
|
| 586 | index 3a3ca0f1236..9d4350a3b7e 100644
|
| 587 | |
| 588 | |
| 589 | @@ -82,9 +82,6 @@ set(TORCH_PYTHON_LINK_LIBRARIES
|
| 590 | Python::Module
|
| 591 | pybind::pybind11
|
| 592 | opentelemetry::api
|
| 593 | - httplib
|
| 594 | - nlohmann
|
| 595 | - moodycamel
|
| 596 | shm
|
| 597 | fmt::fmt-header-only
|
| 598 | ATEN_CPU_FILES_GEN_LIB)
|