mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[Formatting] if (
-> if(
in CMakeLists.txt (#35343)
Summary: Same to `else`, `endif` and `elseif`. Also prefer lowercase over uppercase ones Pull Request resolved: https://github.com/pytorch/pytorch/pull/35343 Test Plan: None at all Differential Revision: D20638789 Pulled By: malfet fbshipit-source-id: 8058075693185e66f5dda7b825b725e139d0d000
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c9117f27c4
commit
512bcf68be
@ -22,7 +22,7 @@ endif()
|
||||
# ---[ Project and semantic versioning.
|
||||
project(Caffe2 CXX C)
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
set(LINUX TRUE)
|
||||
else()
|
||||
set(LINUX FALSE)
|
||||
@ -31,11 +31,11 @@ endif()
|
||||
set(CMAKE_INSTALL_MESSAGE NEVER)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
if (NOT MSVC)
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
endif()
|
||||
if (DEFINED GLIBCXX_USE_CXX11_ABI)
|
||||
if (${GLIBCXX_USE_CXX11_ABI} EQUAL 1)
|
||||
if(DEFINED GLIBCXX_USE_CXX11_ABI)
|
||||
if(${GLIBCXX_USE_CXX11_ABI} EQUAL 1)
|
||||
set(CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=1")
|
||||
endif()
|
||||
@ -47,7 +47,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
# with the main Caffe2 library. This is useful for building modules - if
|
||||
# modules are built with the main Caffe2 library then one does not need to do
|
||||
# find caffe2 in the cmake script. One can usually guard it in some way like
|
||||
# if (NOT CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
|
||||
# if(NOT CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
|
||||
# find_package(Caffe2 REQUIRED)
|
||||
# endif()
|
||||
set(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO ON)
|
||||
@ -81,22 +81,22 @@ if(APPLE)
|
||||
set(CMAKE_MACOSX_RPATH ON)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
if(WIN32)
|
||||
# On Windows, CMAKE_HOST_SYSTEM_PROCESSOR is calculated through `PROCESSOR_ARCHITECTURE`,
|
||||
# which only has the value of `x86` or `AMD64`. We cannot infer whether it's a Intel CPU
|
||||
# or not. However, the environment variable `PROCESSOR_IDENTIFIER` could be used.
|
||||
if ($ENV{PROCESSOR_IDENTIFIER} MATCHES "Intel")
|
||||
if($ENV{PROCESSOR_IDENTIFIER} MATCHES "Intel")
|
||||
set(CPU_INTEL ON)
|
||||
else ()
|
||||
else()
|
||||
set(CPU_INTEL OFF)
|
||||
endif ()
|
||||
else ()
|
||||
if (${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "(x86_64|i[3-6]+86)")
|
||||
endif()
|
||||
else()
|
||||
if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "(x86_64|i[3-6]+86)")
|
||||
set(CPU_INTEL ON)
|
||||
else ()
|
||||
else()
|
||||
set(CPU_INTEL OFF)
|
||||
endif ()
|
||||
endif ()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
# For non-supported platforms, turn USE_DISTRIBUTED off by default.
|
||||
@ -230,7 +230,7 @@ if(LINUX)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-as-needed")
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
foreach(flag_var
|
||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
@ -264,7 +264,7 @@ if (MSVC)
|
||||
# keep using it.
|
||||
string(APPEND ${flag_var} " /w /EHa")
|
||||
|
||||
if (${CAFFE2_USE_MSVC_STATIC_RUNTIME})
|
||||
if(${CAFFE2_USE_MSVC_STATIC_RUNTIME})
|
||||
if(${flag_var} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||
endif(${flag_var} MATCHES "/MD")
|
||||
@ -306,20 +306,20 @@ if (MSVC)
|
||||
list(APPEND CUDA_NVCC_FLAGS "-Xcompiler /w -w")
|
||||
endif(MSVC)
|
||||
|
||||
IF(NOT MSVC)
|
||||
if(NOT MSVC)
|
||||
list(APPEND CUDA_NVCC_FLAGS_DEBUG "-g" "-lineinfo" "--source-in-ptx")
|
||||
list(APPEND CUDA_NVCC_FLAGS_RELWITHDEBINFO "-g" "-lineinfo" "--source-in-ptx")
|
||||
ENDIF(NOT MSVC)
|
||||
endif(NOT MSVC)
|
||||
|
||||
# Set INTERN_BUILD_MOBILE for all mobile builds. Components that are not
|
||||
# applicable to mobile are disabled by this variable.
|
||||
# Setting `BUILD_PYTORCH_MOBILE_WITH_HOST_TOOLCHAIN` environment variable can
|
||||
# force it to do mobile build with host toolchain - which is useful for testing
|
||||
# purpose.
|
||||
if (ANDROID OR IOS OR DEFINED ENV{BUILD_PYTORCH_MOBILE_WITH_HOST_TOOLCHAIN})
|
||||
if(ANDROID OR IOS OR DEFINED ENV{BUILD_PYTORCH_MOBILE_WITH_HOST_TOOLCHAIN})
|
||||
set(INTERN_BUILD_MOBILE ON)
|
||||
|
||||
if (DEFINED ENV{BUILD_PYTORCH_MOBILE_WITH_HOST_TOOLCHAIN})
|
||||
if(DEFINED ENV{BUILD_PYTORCH_MOBILE_WITH_HOST_TOOLCHAIN})
|
||||
# C10_MOBILE is derived from Android/iOS toolchain macros in
|
||||
# c10/macros/Macros.h, so it needs to be explicitly set here.
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DC10_MOBILE")
|
||||
@ -328,7 +328,7 @@ endif()
|
||||
|
||||
# INTERN_BUILD_ATEN_OPS is used to control whether to build ATen/TH operators.
|
||||
# It's disabled for caffe2 mobile library.
|
||||
if (INTERN_BUILD_MOBILE AND BUILD_CAFFE2_MOBILE)
|
||||
if(INTERN_BUILD_MOBILE AND BUILD_CAFFE2_MOBILE)
|
||||
set(INTERN_BUILD_ATEN_OPS OFF)
|
||||
else()
|
||||
set(INTERN_BUILD_ATEN_OPS ON)
|
||||
@ -338,8 +338,8 @@ endif()
|
||||
# When it's enabled it builds original libcaffe2 mobile library without ATen/TH ops nor TorchScript support;
|
||||
# When it's disabled it builds libtorch mobile library, which contains ATen/TH ops and native support for
|
||||
# TorchScript model, but doesn't contain not-yet-unified caffe2 ops;
|
||||
if (INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
|
||||
if (NOT BUILD_SHARED_LIBS)
|
||||
if(INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_EXPORT")
|
||||
endif()
|
||||
set(BUILD_PYTHON OFF)
|
||||
@ -365,11 +365,11 @@ include(cmake/public/utils.cmake)
|
||||
# ---[ Version numbers for generated libraries
|
||||
set(TORCH_DEFAULT_VERSION "1.1.0")
|
||||
set(TORCH_BUILD_VERSION "${TORCH_DEFAULT_VERSION}" CACHE STRING "Torch build version")
|
||||
if (DEFINED ENV{PYTORCH_BUILD_VERSION})
|
||||
if(DEFINED ENV{PYTORCH_BUILD_VERSION})
|
||||
set(TORCH_BUILD_VERSION "$ENV{PYTORCH_BUILD_VERSION}"
|
||||
CACHE STRING "Torch build version" FORCE)
|
||||
endif()
|
||||
if (NOT TORCH_BUILD_VERSION)
|
||||
if(NOT TORCH_BUILD_VERSION)
|
||||
# An empty string was specified so force version to the default
|
||||
set(TORCH_BUILD_VERSION "${TORCH_DEFAULT_VERSION}"
|
||||
CACHE STRING "Torch build version" FORCE)
|
||||
@ -459,7 +459,7 @@ if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-overflow")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-aliasing")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=deprecated-declarations")
|
||||
if (CMAKE_COMPILER_IS_GNUCXX AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0))
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0.0))
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-overflow")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=pedantic")
|
||||
@ -467,7 +467,7 @@ if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=old-style-cast")
|
||||
# These flags are not available in GCC-4.8.5. Set only when using clang.
|
||||
# Compared against https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Option-Summary.html
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-partial-specialization")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-typedef-redefinition")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option")
|
||||
@ -478,29 +478,29 @@ if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-constexpr-not-const")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")
|
||||
if (${COLORIZE_OUTPUT})
|
||||
if(${COLORIZE_OUTPUT})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics")
|
||||
endif()
|
||||
endif()
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
|
||||
if (${COLORIZE_OUTPUT})
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9)
|
||||
if(${COLORIZE_OUTPUT})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
|
||||
endif()
|
||||
endif()
|
||||
if ((APPLE AND (NOT ("${CLANG_VERSION_STRING}" VERSION_LESS "9.0")))
|
||||
if((APPLE AND (NOT ("${CLANG_VERSION_STRING}" VERSION_LESS "9.0")))
|
||||
OR (CMAKE_COMPILER_IS_GNUCXX
|
||||
AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0 AND NOT APPLE)))
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -faligned-new")
|
||||
endif()
|
||||
if (WERROR)
|
||||
if(WERROR)
|
||||
check_cxx_compiler_flag("-Werror" COMPILER_SUPPORT_WERROR)
|
||||
if (NOT COMPILER_SUPPORT_WERROR)
|
||||
if(NOT COMPILER_SUPPORT_WERROR)
|
||||
set(WERROR FALSE)
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||
endif()
|
||||
endif(WERROR)
|
||||
if (NOT APPLE)
|
||||
if(NOT APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized")
|
||||
endif()
|
||||
@ -509,24 +509,24 @@ if(NOT MSVC)
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-math-errno")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-trapping-math")
|
||||
check_cxx_compiler_flag("-Werror=format" HAS_WERROR_FORMAT)
|
||||
if (HAS_WERROR_FORMAT)
|
||||
if(HAS_WERROR_FORMAT)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=format")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (USE_ASAN)
|
||||
if(USE_ASAN)
|
||||
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address")
|
||||
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_STATIC_LINKER_FLAGS_DEBUG} -fsanitize=address")
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
if(APPLE)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-private-field")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++14-extensions")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-constexpr-not-const")
|
||||
endif()
|
||||
|
||||
if (EMSCRIPTEN)
|
||||
if(EMSCRIPTEN)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-implicit-function-declaration -DEMSCRIPTEN -s DISABLE_EXCEPTION_CATCHING=0")
|
||||
endif()
|
||||
|
||||
@ -568,7 +568,7 @@ add_subdirectory(caffe2)
|
||||
if(BUILD_DOCS)
|
||||
# check if Doxygen is installed
|
||||
find_package(Doxygen)
|
||||
if (DOXYGEN_FOUND)
|
||||
if(DOXYGEN_FOUND)
|
||||
message("Generating documentation")
|
||||
|
||||
set(DOXYGEN_C_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/caffe2/.Doxyfile-c)
|
||||
@ -616,14 +616,14 @@ endif()
|
||||
# ---[ Make configuration files for cmake to allow dependent libraries
|
||||
# easier access to Caffe2.
|
||||
|
||||
if ((NOT USE_GLOG) OR (NOT USE_GFLAGS) OR BUILD_CUSTOM_PROTOBUF)
|
||||
if((NOT USE_GLOG) OR (NOT USE_GFLAGS) OR BUILD_CUSTOM_PROTOBUF)
|
||||
message(WARNING
|
||||
"Generated cmake files are only fully tested if one builds "
|
||||
"with system glog, gflags, and protobuf. Other settings may "
|
||||
"generate files that are not well tested.")
|
||||
endif()
|
||||
|
||||
if (USE_CUDA OR USE_ROCM)
|
||||
if(USE_CUDA OR USE_ROCM)
|
||||
# TODO: check if we should include other cuda dependency libraries
|
||||
# to the interface as well.
|
||||
|
||||
@ -635,7 +635,7 @@ endif()
|
||||
# script will fail. As a result, we will only provide the targets cmake
|
||||
# files for shared lib installation. For more info, read:
|
||||
# https://cmake.org/pipermail/cmake/2016-May/063400.html
|
||||
if (BUILD_SHARED_LIBS)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
configure_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Caffe2ConfigVersion.cmake.in
|
||||
${PROJECT_BINARY_DIR}/Caffe2ConfigVersion.cmake
|
||||
@ -682,12 +682,12 @@ add_subdirectory(modules)
|
||||
# are built. For the binaries, they will be linked to the Caffe2 main
|
||||
# libraries, as well as all the modules that are built with Caffe2 (the ones
|
||||
# built in the previous Modules section above).
|
||||
if (BUILD_BINARY)
|
||||
if(BUILD_BINARY)
|
||||
add_subdirectory(binaries)
|
||||
endif()
|
||||
|
||||
# ---[ JNI
|
||||
if (BUILD_JNI)
|
||||
if(BUILD_JNI)
|
||||
set(BUILD_LIBTORCH_WITH_JNI 1)
|
||||
set(FBJNI_SKIP_TESTS 1)
|
||||
add_subdirectory(android/pytorch_android)
|
||||
|
@ -60,7 +60,7 @@ endif()
|
||||
file(GLOB tbb_src "${TBB_ROOT_DIR}/src/tbb/*.cpp" "${TBB_ROOT_DIR}/src/old/*.cpp")
|
||||
list(APPEND tbb_src ${TBB_ROOT_DIR}/src/rml/client/rml_tbb.cpp)
|
||||
file(GLOB to_remove "${TBB_ROOT_DIR}/src/old/test*.cpp")
|
||||
if (NOT "${to_remove}" STREQUAL "")
|
||||
if(NOT "${to_remove}" STREQUAL "")
|
||||
list(REMOVE_ITEM tbb_src ${to_remove})
|
||||
endif()
|
||||
|
||||
@ -78,13 +78,13 @@ set(tbbmalloc_proxy_src
|
||||
src/tbbmalloc/proxy.cpp
|
||||
src/tbbmalloc/tbb_function_replacement.cpp)
|
||||
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(i386|x86_64)")
|
||||
if (NOT APPLE AND NOT MINGW)
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "(i386|x86_64)")
|
||||
if(NOT APPLE AND NOT MINGW)
|
||||
add_definitions(-DDO_ITT_NOTIFY)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (APPLE)
|
||||
if(APPLE)
|
||||
# Disable annoying "has no symbols" warnings
|
||||
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||
@ -102,12 +102,12 @@ macro(CHECK_CXX_COMPILER_AND_LINKER_FLAGS _RESULT _CXX_FLAGS _LINKER_FLAGS)
|
||||
endmacro()
|
||||
|
||||
# Prefer libc++ in conjunction with Clang
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
if (CMAKE_CXX_FLAGS MATCHES "-stdlib=libc\\+\\+")
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
if(CMAKE_CXX_FLAGS MATCHES "-stdlib=libc\\+\\+")
|
||||
message(STATUS "TBB: using libc++.")
|
||||
else()
|
||||
CHECK_CXX_COMPILER_AND_LINKER_FLAGS(HAS_LIBCPP "-stdlib=libc++" "-stdlib=libc++")
|
||||
if (HAS_LIBCPP)
|
||||
if(HAS_LIBCPP)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -D_LIBCPP_VERSION")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libc++")
|
||||
@ -118,35 +118,35 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (UNIX)
|
||||
if(UNIX)
|
||||
add_definitions (-DUSE_PTHREAD)
|
||||
|
||||
check_cxx_compiler_flag ("-std=c++14" SUPPORTS_STDCXX14)
|
||||
if (SUPPORTS_STDCXX14)
|
||||
if(SUPPORTS_STDCXX14)
|
||||
set (CMAKE_CXX_FLAGS "-std=c++14 ${CMAKE_CXX_FLAGS}")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
check_cxx_compiler_flag ("-mrtm -Werror" SUPPORTS_MRTM)
|
||||
if (SUPPORTS_MRTM)
|
||||
if(SUPPORTS_MRTM)
|
||||
set (CMAKE_CXX_FLAGS "-mrtm ${CMAKE_CXX_FLAGS}")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
elseif(WIN32)
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
cmake_minimum_required (VERSION 3.1)
|
||||
enable_language(ASM_MASM)
|
||||
set(CMAKE_CXX_FLAGS "/GS- /Zc:wchar_t /Zc:forScope /DUSE_WINTHREAD ${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "/D_CRT_SECURE_NO_DEPRECATE /D_WIN32_WINNT=0x0600 ${CMAKE_CXX_FLAGS}")
|
||||
check_cxx_compiler_flag ("/volatile:iso" SUPPORTS_VOLATILE_FLAG)
|
||||
if (SUPPORTS_VOLATILE_FLAG)
|
||||
if(SUPPORTS_VOLATILE_FLAG)
|
||||
set(CMAKE_CXX_FLAGS "/volatile:iso ${CMAKE_CXX_FLAGS}")
|
||||
endif ()
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS "/wd4267 /wd4800 /wd4146 /wd4244 /wd4577 /wd4018 ${CMAKE_CXX_FLAGS}")
|
||||
if (NOT CMAKE_SIZEOF_VOID_P)
|
||||
if(NOT CMAKE_SIZEOF_VOID_P)
|
||||
message(FATAL_ERROR "'CMAKE_SIZEOF_VOID_P' is undefined. Please delete your build directory and rerun CMake again!")
|
||||
endif()
|
||||
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
list(APPEND tbb_src "${TBB_ROOT_DIR}/src/tbb/intel64-masm/atomic_support.asm")
|
||||
list(APPEND tbb_src "${TBB_ROOT_DIR}/src/tbb/intel64-masm/itsx.asm")
|
||||
list(APPEND tbb_src "${TBB_ROOT_DIR}/src/tbb/intel64-masm/intel64_misc.asm")
|
||||
@ -158,47 +158,47 @@ elseif(WIN32)
|
||||
# Enable SAFESEH feature for assembly (x86 builds only).
|
||||
set(CMAKE_ASM_MASM_FLAGS "/safeseh ${CMAKE_ASM_MASM_FLAGS}")
|
||||
endif()
|
||||
elseif (MINGW)
|
||||
elseif(MINGW)
|
||||
add_definitions(-DUSE_WINTHREAD)
|
||||
add_definitions(-D_WIN32_WINNT=0x0502)
|
||||
set(CMAKE_CXX_FLAGS "-mthreads ${CMAKE_CXX_FLAGS}")
|
||||
endif ()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
set(ENABLE_RTTI "/EHsc /GR ")
|
||||
set(DISABLE_RTTI "/EHs- /GR- ")
|
||||
elseif (UNIX)
|
||||
elseif(UNIX)
|
||||
set(ENABLE_RTTI "-frtti -fexceptions ")
|
||||
set(DISABLE_RTTI "-fno-rtti -fno-exceptions ")
|
||||
endif ()
|
||||
endif()
|
||||
|
||||
##--------
|
||||
# - Added TBB_USE_GLIBCXX_VERSION macro to specify the version of GNU
|
||||
# libstdc++ when it cannot be properly recognized, e.g. when used
|
||||
# with Clang on Linux* OS. Inspired by a contribution from David A.
|
||||
if (NOT TBB_USE_GLIBCXX_VERSION AND UNIX AND NOT APPLE)
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
if(NOT TBB_USE_GLIBCXX_VERSION AND UNIX AND NOT APPLE)
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
# using Clang
|
||||
string(REPLACE "." "0" TBB_USE_GLIBCXX_VERSION ${CMAKE_CXX_COMPILER_VERSION})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (TBB_USE_GLIBCXX_VERSION)
|
||||
if(TBB_USE_GLIBCXX_VERSION)
|
||||
add_definitions(-DTBB_USE_GLIBCXX_VERSION=${TBB_USE_GLIBCXX_VERSION})
|
||||
endif()
|
||||
|
||||
##-------
|
||||
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
check_cxx_compiler_flag ("-flifetime-dse=1" SUPPORTS_FLIFETIME)
|
||||
if (SUPPORTS_FLIFETIME)
|
||||
if(SUPPORTS_FLIFETIME)
|
||||
add_definitions(-flifetime-dse=1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Linker export definitions
|
||||
if (APPLE)
|
||||
if(APPLE)
|
||||
set (ARCH_PREFIX "mac")
|
||||
elseif(WIN32)
|
||||
set (ARCH_PREFIX "win")
|
||||
@ -206,19 +206,19 @@ else()
|
||||
set (ARCH_PREFIX "lin")
|
||||
endif()
|
||||
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(ARCH_PREFIX "${ARCH_PREFIX}64")
|
||||
else()
|
||||
set(ARCH_PREFIX "${ARCH_PREFIX}32")
|
||||
endif()
|
||||
|
||||
if (MINGW)
|
||||
if(MINGW)
|
||||
set (ARCH_PREFIX "${ARCH_PREFIX}-gcc")
|
||||
# there's no win32-gcc-tbb-export.def, use lin32-tbb-export.def
|
||||
execute_process (COMMAND ${CMAKE_COMMAND} -E copy ${TBB_ROOT_DIR}/src/tbb/lin32-tbb-export.def ${TBB_ROOT_DIR}/src/tbb/win32-gcc-tbb-export.def)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
add_custom_command(OUTPUT tbb.def
|
||||
COMMAND ${CMAKE_CXX_COMPILER} /TC /EP ${TBB_ROOT_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def -I ${TBB_ROOT_DIR}/include > tbb.def
|
||||
MAIN_DEPENDENCY ${TBB_ROOT_DIR}/src/tbb/${ARCH_PREFIX}-tbb-export.def
|
||||
@ -247,7 +247,7 @@ endif()
|
||||
add_custom_target(tbb_def_files DEPENDS tbb.def tbbmalloc.def)
|
||||
|
||||
# TBB library
|
||||
if (TBB_BUILD_STATIC)
|
||||
if(TBB_BUILD_STATIC)
|
||||
add_library(tbb_static STATIC ${tbb_src})
|
||||
target_include_directories(tbb_static PRIVATE ${TBB_INCLUDES})
|
||||
set_property(TARGET tbb_static APPEND PROPERTY COMPILE_DEFINITIONS "__TBB_BUILD=1")
|
||||
@ -255,27 +255,27 @@ if (TBB_BUILD_STATIC)
|
||||
install(TARGETS tbb_static
|
||||
EXPORT ${TBB_INSTALL_EXPORT_NAME} DESTINATION ${TBB_INSTALL_EXPORT_DESTINATION}
|
||||
ARCHIVE DESTINATION ${TBB_INSTALL_ARCHIVE_DIR})
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
target_compile_definitions(tbb_static PUBLIC __TBB_NO_IMPLICIT_LINKAGE=1)
|
||||
endif()
|
||||
|
||||
if (UNIX AND NOT APPLE)
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_link_libraries(tbb_static PUBLIC pthread dl)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (TBB_BUILD_SHARED)
|
||||
if(TBB_BUILD_SHARED)
|
||||
add_library(tbb SHARED ${tbb_src})
|
||||
target_include_directories(tbb PRIVATE ${TBB_INCLUDES})
|
||||
set_property(TARGET tbb APPEND PROPERTY COMPILE_DEFINITIONS "__TBB_BUILD=1")
|
||||
set_property(TARGET tbb APPEND_STRING PROPERTY COMPILE_FLAGS ${ENABLE_RTTI})
|
||||
add_dependencies(tbb tbb_def_files)
|
||||
|
||||
if (APPLE)
|
||||
if(APPLE)
|
||||
set_property(TARGET tbb APPEND PROPERTY LINK_FLAGS "-Wl,-exported_symbols_list,\"${CMAKE_CURRENT_BINARY_DIR}/tbb.def\"")
|
||||
elseif (MSVC)
|
||||
elseif(MSVC)
|
||||
set_property(TARGET tbb APPEND PROPERTY LINK_FLAGS "/DEF:\"${CMAKE_CURRENT_BINARY_DIR}/tbb.def\"")
|
||||
else ()
|
||||
else()
|
||||
set_property(TARGET tbb APPEND PROPERTY LINK_FLAGS "-Wl,-version-script,\"${CMAKE_CURRENT_BINARY_DIR}/tbb.def\"")
|
||||
endif()
|
||||
|
||||
@ -284,10 +284,10 @@ if (TBB_BUILD_SHARED)
|
||||
LIBRARY DESTINATION ${TBB_INSTALL_LIBRARY_DIR}
|
||||
ARCHIVE DESTINATION ${TBB_INSTALL_ARCHIVE_DIR}
|
||||
RUNTIME DESTINATION ${TBB_INSTALL_RUNTIME_DIR})
|
||||
if (UNIX AND NOT APPLE)
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_link_libraries(tbb PUBLIC pthread dl)
|
||||
endif()
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
target_compile_definitions(tbb PUBLIC __TBB_NO_IMPLICIT_LINKAGE=1)
|
||||
endif()
|
||||
endif()
|
||||
@ -306,12 +306,12 @@ endif()
|
||||
|
||||
if(TBB_BUILD_TBBMALLOC)
|
||||
# TBB malloc library
|
||||
if (TBB_BUILD_STATIC)
|
||||
if(TBB_BUILD_STATIC)
|
||||
add_library(tbbmalloc_static STATIC ${tbbmalloc_static_src})
|
||||
target_include_directories(tbbmalloc_static PRIVATE ${TBB_INCLUDES})
|
||||
set_property(TARGET tbbmalloc_static APPEND PROPERTY COMPILE_DEFINITIONS "__TBBMALLOC_BUILD=1")
|
||||
set_property(TARGET tbbmalloc_static APPEND_STRING PROPERTY COMPILE_FLAGS ${DISABLE_RTTI})
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
target_compile_definitions(tbbmalloc_static PUBLIC __TBB_NO_IMPLICIT_LINKAGE=1 __TBBMALLOC_NO_IMPLICIT_LINKAGE=1)
|
||||
endif()
|
||||
install(TARGETS tbbmalloc_static
|
||||
@ -319,20 +319,20 @@ if(TBB_BUILD_TBBMALLOC)
|
||||
ARCHIVE DESTINATION ${TBB_INSTALL_ARCHIVE_DIR})
|
||||
endif()
|
||||
|
||||
if (TBB_BUILD_SHARED)
|
||||
if(TBB_BUILD_SHARED)
|
||||
add_library(tbbmalloc SHARED ${tbbmalloc_src})
|
||||
target_include_directories(tbbmalloc PRIVATE ${TBB_INCLUDES})
|
||||
set_property(TARGET tbbmalloc APPEND PROPERTY COMPILE_DEFINITIONS "__TBBMALLOC_BUILD=1")
|
||||
set_property(TARGET tbbmalloc APPEND_STRING PROPERTY COMPILE_FLAGS ${DISABLE_RTTI})
|
||||
add_dependencies(tbbmalloc tbb_def_files)
|
||||
if (APPLE)
|
||||
if(APPLE)
|
||||
set_property(TARGET tbbmalloc APPEND PROPERTY LINK_FLAGS "-Wl,-exported_symbols_list,\"${CMAKE_CURRENT_BINARY_DIR}/tbbmalloc.def\"")
|
||||
elseif (MSVC)
|
||||
elseif(MSVC)
|
||||
set_property(TARGET tbbmalloc APPEND PROPERTY LINK_FLAGS "/DEF:\"${CMAKE_CURRENT_BINARY_DIR}/tbbmalloc.def\"")
|
||||
else ()
|
||||
else()
|
||||
set_property(TARGET tbbmalloc APPEND PROPERTY LINK_FLAGS "-Wl,-version-script,\"${CMAKE_CURRENT_BINARY_DIR}/tbbmalloc.def\"")
|
||||
endif()
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
target_compile_definitions(tbbmalloc PUBLIC __TBB_NO_IMPLICIT_LINKAGE=1 __TBBMALLOC_NO_IMPLICIT_LINKAGE=1)
|
||||
endif()
|
||||
install(TARGETS tbbmalloc
|
||||
@ -340,7 +340,7 @@ if(TBB_BUILD_TBBMALLOC)
|
||||
LIBRARY DESTINATION ${TBB_INSTALL_LIBRARY_DIR}
|
||||
ARCHIVE DESTINATION ${TBB_INSTALL_ARCHIVE_DIR}
|
||||
RUNTIME DESTINATION ${TBB_INSTALL_RUNTIME_DIR})
|
||||
if (UNIX AND NOT APPLE)
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_link_libraries(tbbmalloc PUBLIC pthread dl)
|
||||
endif()
|
||||
endif()
|
||||
@ -348,7 +348,7 @@ endif()
|
||||
|
||||
if(TBB_BUILD_TBBMALLOC_PROXY)
|
||||
# TBB malloc proxy library
|
||||
if (TBB_BUILD_STATIC)
|
||||
if(TBB_BUILD_STATIC)
|
||||
add_library(tbbmalloc_proxy_static STATIC ${tbbmalloc_proxy_src})
|
||||
set_property(TARGET tbbmalloc_proxy_static APPEND PROPERTY COMPILE_DEFINITIONS "__TBBMALLOC_BUILD=1")
|
||||
set_property(TARGET tbbmalloc_proxy_static APPEND_STRING PROPERTY COMPILE_FLAGS ${DISABLE_RTTI})
|
||||
@ -357,7 +357,7 @@ if(TBB_BUILD_TBBMALLOC_PROXY)
|
||||
ARCHIVE DESTINATION ${TBB_INSTALL_ARCHIVE_DIR})
|
||||
endif()
|
||||
|
||||
if (TBB_BUILD_SHARED)
|
||||
if(TBB_BUILD_SHARED)
|
||||
add_library(tbbmalloc_proxy SHARED ${tbbmalloc_proxy_src})
|
||||
set_property(TARGET tbbmalloc_proxy APPEND PROPERTY COMPILE_DEFINITIONS "__TBBMALLOC_BUILD=1")
|
||||
set_property(TARGET tbbmalloc_proxy APPEND_STRING PROPERTY COMPILE_FLAGS ${DISABLE_RTTI})
|
||||
@ -367,7 +367,7 @@ if(TBB_BUILD_TBBMALLOC_PROXY)
|
||||
LIBRARY DESTINATION ${TBB_INSTALL_LIBRARY_DIR}
|
||||
ARCHIVE DESTINATION ${TBB_INSTALL_ARCHIVE_DIR}
|
||||
RUNTIME DESTINATION ${TBB_INSTALL_RUNTIME_DIR})
|
||||
if (UNIX AND NOT APPLE)
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_link_libraries(tbbmalloc_proxy PUBLIC pthread dl)
|
||||
endif()
|
||||
endif()
|
||||
@ -376,15 +376,15 @@ endif()
|
||||
install(DIRECTORY "${TBB_ROOT_DIR}/include/tbb" DESTINATION ${TBB_INSTALL_INCLUDE_DIR})
|
||||
|
||||
# version_string.ver
|
||||
if (UNIX)
|
||||
if(UNIX)
|
||||
execute_process (COMMAND date "+%a, %d %b %Y %H:%M:%S %z"
|
||||
OUTPUT_VARIABLE _configure_date
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
elseif (WIN32)
|
||||
elseif(WIN32)
|
||||
execute_process (COMMAND cmd " /C date /T"
|
||||
OUTPUT_VARIABLE _configure_date
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
else ()
|
||||
else()
|
||||
set (_configure_date "Unknown")
|
||||
endif()
|
||||
include_directories (${CMAKE_BINARY_DIR})
|
||||
|
@ -4,7 +4,7 @@ include(../cmake/Codegen.cmake)
|
||||
# ---[ Declare source file lists
|
||||
|
||||
# ---[ ATen build
|
||||
if (INTERN_BUILD_ATEN_OPS)
|
||||
if(INTERN_BUILD_ATEN_OPS)
|
||||
set(__caffe2_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE})
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
add_subdirectory(../aten aten)
|
||||
@ -51,15 +51,15 @@ endif()
|
||||
# addressed yet.
|
||||
|
||||
# For pthreadpool_new_if_impl. TODO: Remove when threadpools are unitied.
|
||||
if (NOT MSVC)
|
||||
IF(NOT TARGET fxdiv)
|
||||
if(NOT MSVC)
|
||||
if(NOT TARGET fxdiv)
|
||||
SET(FXDIV_BUILD_TESTS OFF CACHE BOOL "")
|
||||
SET(FXDIV_BUILD_BENCHMARKS OFF CACHE BOOL "")
|
||||
ADD_SUBDIRECTORY(
|
||||
"${FXDIV_SOURCE_DIR}"
|
||||
"${CMAKE_BINARY_DIR}/FXdiv")
|
||||
ENDIF()
|
||||
if (NOT (INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE))
|
||||
endif()
|
||||
if(NOT (INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE))
|
||||
set_source_files_properties(
|
||||
utils/threadpool/pthreadpool_new_if_impl.c PROPERTIES COMPILE_FLAGS -fno-openmp)
|
||||
endif()
|
||||
@ -71,12 +71,12 @@ add_subdirectory(utils)
|
||||
add_subdirectory(perfkernels)
|
||||
|
||||
# Skip modules that are not used by libtorch mobile yet.
|
||||
if (NOT INTERN_BUILD_MOBILE OR BUILD_CAFFE2_MOBILE)
|
||||
if(NOT INTERN_BUILD_MOBILE OR BUILD_CAFFE2_MOBILE)
|
||||
add_subdirectory(contrib)
|
||||
add_subdirectory(predictor)
|
||||
add_subdirectory(predictor/emulator)
|
||||
add_subdirectory(core/nomnigraph)
|
||||
if (USE_NVRTC)
|
||||
if(USE_NVRTC)
|
||||
add_subdirectory(cuda_rtc)
|
||||
endif()
|
||||
add_subdirectory(db)
|
||||
@ -89,14 +89,14 @@ if (NOT INTERN_BUILD_MOBILE OR BUILD_CAFFE2_MOBILE)
|
||||
add_subdirectory(mpi)
|
||||
add_subdirectory(observers)
|
||||
add_subdirectory(onnx)
|
||||
if (BUILD_CAFFE2_OPS)
|
||||
if(BUILD_CAFFE2_OPS)
|
||||
add_subdirectory(operators)
|
||||
add_subdirectory(operators/rnn)
|
||||
if (USE_FBGEMM)
|
||||
if(USE_FBGEMM)
|
||||
add_subdirectory(quantization)
|
||||
add_subdirectory(quantization/server)
|
||||
endif()
|
||||
if (USE_QNNPACK)
|
||||
if(USE_QNNPACK)
|
||||
add_subdirectory(operators/quantized)
|
||||
endif()
|
||||
endif()
|
||||
@ -112,7 +112,7 @@ endif()
|
||||
|
||||
# Advanced: if we have white list specified, we will do intersections for all
|
||||
# main lib srcs.
|
||||
if (CAFFE2_WHITELISTED_FILES)
|
||||
if(CAFFE2_WHITELISTED_FILES)
|
||||
caffe2_do_whitelist(Caffe2_CPU_SRCS CAFFE2_WHITELISTED_FILES)
|
||||
caffe2_do_whitelist(Caffe2_GPU_SRCS CAFFE2_WHITELISTED_FILES)
|
||||
caffe2_do_whitelist(Caffe2_HIP_SRCS CAFFE2_WHITELISTED_FILES)
|
||||
@ -120,7 +120,7 @@ endif()
|
||||
|
||||
# Debug messages - if you want to get a list of source files, enable the
|
||||
# following.
|
||||
if (FALSE)
|
||||
if(FALSE)
|
||||
message(STATUS "CPU sources: ")
|
||||
foreach(tmp ${Caffe2_CPU_SRCS})
|
||||
message(STATUS " " ${tmp})
|
||||
@ -177,7 +177,7 @@ if (FALSE)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if (NOT INTERN_BUILD_MOBILE OR BUILD_CAFFE2_MOBILE)
|
||||
if(NOT INTERN_BUILD_MOBILE OR BUILD_CAFFE2_MOBILE)
|
||||
# ---[ List of libraries to link with
|
||||
add_library(caffe2_protos STATIC $<TARGET_OBJECTS:Caffe2_PROTO>)
|
||||
add_dependencies(caffe2_protos Caffe2_PROTO)
|
||||
@ -210,7 +210,7 @@ if (NOT INTERN_BUILD_MOBILE OR BUILD_CAFFE2_MOBILE)
|
||||
# nothing changes. If one has a dependent library that uses protobuf, then one needs to
|
||||
# have the right protobuf version as well as linking to libprotobuf.a.
|
||||
target_link_libraries(caffe2_protos PUBLIC protobuf::libprotobuf)
|
||||
if (NOT BUILD_SHARED_LIBS)
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
INSTALL(TARGETS caffe2_protos ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
endif()
|
||||
@ -236,7 +236,7 @@ endif()
|
||||
|
||||
|
||||
|
||||
if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
||||
if(NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
||||
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||
@ -493,7 +493,7 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
||||
${TORCH_SRC_DIR}/csrc/jit/mobile/type_parser.cpp
|
||||
)
|
||||
|
||||
if (NOT INTERN_DISABLE_MOBILE_INTERP)
|
||||
if(NOT INTERN_DISABLE_MOBILE_INTERP)
|
||||
set (MOBILE_SRCS
|
||||
${TORCH_SRC_DIR}/csrc/jit/mobile/function.cpp
|
||||
${TORCH_SRC_DIR}/csrc/jit/mobile/import.cpp
|
||||
@ -505,13 +505,13 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
||||
list (APPEND TORCH_SRCS ${MOBILE_SRCS})
|
||||
endif()
|
||||
|
||||
if (NOT INTERN_DISABLE_AUTOGRAD)
|
||||
if(NOT INTERN_DISABLE_AUTOGRAD)
|
||||
list(APPEND TORCH_SRCS
|
||||
${TORCH_SRC_DIR}/csrc/autograd/VariableTypeManual.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT INTERN_BUILD_MOBILE)
|
||||
if(NOT INTERN_BUILD_MOBILE)
|
||||
list(APPEND TORCH_SRCS
|
||||
${TORCH_SRC_DIR}/csrc/api/src/jit.cpp
|
||||
${TORCH_SRC_DIR}/csrc/jit/serialization/export.cpp
|
||||
@ -521,7 +521,7 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
||||
${TORCH_SRC_DIR}/csrc/jit/api/module_save.cpp
|
||||
${TORCH_SRC_DIR}/csrc/utils/byte_order.cpp
|
||||
)
|
||||
if (USE_DISTRIBUTED)
|
||||
if(USE_DISTRIBUTED)
|
||||
list(APPEND TORCH_SRCS
|
||||
${TORCH_SRC_DIR}/csrc/distributed/autograd/context/container.cpp
|
||||
${TORCH_SRC_DIR}/csrc/distributed/autograd/context/context.cpp
|
||||
@ -554,7 +554,7 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (USE_CUDA)
|
||||
if(USE_CUDA)
|
||||
list(APPEND Caffe2_GPU_SRCS
|
||||
${TORCH_SRC_DIR}/csrc/jit/codegen/fuser/cuda/fused_kernel.cpp
|
||||
${TORCH_SRC_DIR}/csrc/autograd/profiler_cuda.cpp
|
||||
@ -566,13 +566,13 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
||||
target_link_libraries(caffe2_nvrtc ${CUDA_NVRTC} ${CUDA_CUDA_LIB} ${CUDA_NVRTC_LIB})
|
||||
target_include_directories(caffe2_nvrtc PRIVATE ${CUDA_INCLUDE_DIRS})
|
||||
install(TARGETS caffe2_nvrtc DESTINATION "${TORCH_INSTALL_LIB_DIR}")
|
||||
if (USE_NCCL)
|
||||
if(USE_NCCL)
|
||||
list(APPEND Caffe2_GPU_SRCS
|
||||
${TORCH_SRC_DIR}/csrc/cuda/nccl.cpp)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (USE_ROCM)
|
||||
if(USE_ROCM)
|
||||
list(APPEND Caffe2_HIP_SRCS
|
||||
${TORCH_SRC_DIR}/csrc/jit/codegen/fuser/cuda/fused_kernel.cpp
|
||||
${TORCH_SRC_DIR}/csrc/autograd/profiler_cuda.cpp
|
||||
@ -580,7 +580,7 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
||||
${TORCH_SRC_DIR}/csrc/cuda/comm.cpp
|
||||
${TORCH_SRC_DIR}/csrc/jit/tensorexpr/cuda_codegen.cpp
|
||||
)
|
||||
if (USE_NCCL)
|
||||
if(USE_NCCL)
|
||||
list(APPEND Caffe2_HIP_SRCS
|
||||
${TORCH_SRC_DIR}/csrc/cuda/nccl.cpp)
|
||||
endif()
|
||||
@ -592,7 +592,7 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
||||
install(TARGETS caffe2_nvrtc DESTINATION "${TORCH_INSTALL_LIB_DIR}")
|
||||
endif()
|
||||
|
||||
if (NOT NO_API)
|
||||
if(NOT NO_API)
|
||||
list(APPEND TORCH_SRCS
|
||||
${TORCH_SRC_DIR}/csrc/api/src/cuda.cpp
|
||||
${TORCH_SRC_DIR}/csrc/api/src/data/datasets/mnist.cpp
|
||||
@ -660,18 +660,18 @@ endif()
|
||||
add_library(torch_cpu ${Caffe2_CPU_SRCS})
|
||||
torch_compile_options(torch_cpu) # see cmake/public/utils.cmake
|
||||
|
||||
if (USE_LLVM AND LLVM_FOUND)
|
||||
if(USE_LLVM AND LLVM_FOUND)
|
||||
llvm_map_components_to_libnames(LLVM_LINK_LIBS
|
||||
support core analysis executionengine instcombine
|
||||
scalaropts transformutils native orcjit)
|
||||
target_link_libraries(torch_cpu PRIVATE ${LLVM_LINK_LIBS})
|
||||
endif (USE_LLVM AND LLVM_FOUND)
|
||||
endif(USE_LLVM AND LLVM_FOUND)
|
||||
|
||||
# This is required for older versions of CMake, which don't allow
|
||||
# specifying add_library() without a list of source files
|
||||
set(DUMMY_EMPTY_FILE ${CMAKE_BINARY_DIR}/empty.cpp)
|
||||
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
set(DUMMY_FILE_CONTENT "__declspec(dllexport) int ignore_this_library_placeholder(){return 0\\;}")
|
||||
else()
|
||||
set(DUMMY_FILE_CONTENT "")
|
||||
@ -689,29 +689,29 @@ if(USE_ROCM)
|
||||
endif()
|
||||
|
||||
# Compile exposed libraries.
|
||||
IF (USE_ROCM)
|
||||
if(USE_ROCM)
|
||||
set(CUDA_LINK_LIBRARIES_KEYWORD PRIVATE)
|
||||
hip_add_library(torch_hip ${Caffe2_HIP_SRCS})
|
||||
set(CUDA_LINK_LIBRARIES_KEYWORD)
|
||||
torch_compile_options(torch_hip) # see cmake/public/utils.cmake
|
||||
# TODO: Not totally sure if this is live or not
|
||||
if (USE_NCCL)
|
||||
if(USE_NCCL)
|
||||
target_link_libraries(torch_hip PRIVATE __caffe2_nccl)
|
||||
target_compile_definitions(torch_hip PRIVATE USE_NCCL)
|
||||
endif()
|
||||
ELSEIF(USE_CUDA)
|
||||
elseif(USE_CUDA)
|
||||
set(CUDA_LINK_LIBRARIES_KEYWORD PRIVATE)
|
||||
cuda_add_library(torch_cuda ${Caffe2_GPU_SRCS})
|
||||
set(CUDA_LINK_LIBRARIES_KEYWORD)
|
||||
torch_compile_options(torch_cuda) # see cmake/public/utils.cmake
|
||||
if (USE_NCCL)
|
||||
if(USE_NCCL)
|
||||
target_link_libraries(torch_cuda PRIVATE __caffe2_nccl)
|
||||
target_compile_definitions(torch_cuda PRIVATE USE_NCCL)
|
||||
endif()
|
||||
ENDIF()
|
||||
endif()
|
||||
|
||||
|
||||
if (NOT MSVC)
|
||||
if(NOT MSVC)
|
||||
TARGET_LINK_LIBRARIES(torch_cpu PRIVATE fxdiv)
|
||||
endif()
|
||||
|
||||
@ -719,7 +719,7 @@ endif()
|
||||
# formerly-libtorch flags
|
||||
# ==========================================================
|
||||
|
||||
if (NOT INTERN_BUILD_MOBILE)
|
||||
if(NOT INTERN_BUILD_MOBILE)
|
||||
# Forces caffe2.pb.h to be generated before its dependents are compiled.
|
||||
# Adding the generated header file to the ${TORCH_SRCS} list is not sufficient
|
||||
# to establish the dependency, since the generation procedure is declared in a different CMake file.
|
||||
@ -727,8 +727,8 @@ if (NOT INTERN_BUILD_MOBILE)
|
||||
add_dependencies(torch_cpu Caffe2_PROTO)
|
||||
endif()
|
||||
|
||||
if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
||||
if (NOT NO_API)
|
||||
if(NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
||||
if(NOT NO_API)
|
||||
target_include_directories(torch_cpu PRIVATE
|
||||
${TORCH_SRC_DIR}/csrc/api
|
||||
${TORCH_SRC_DIR}/csrc/api/include)
|
||||
@ -736,10 +736,10 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
||||
|
||||
if(USE_CUDA)
|
||||
if(MSVC)
|
||||
if (NOT NVTOOLEXT_HOME)
|
||||
if(NOT NVTOOLEXT_HOME)
|
||||
set(NVTOOLEXT_HOME "C:/Program Files/NVIDIA Corporation/NvToolsExt")
|
||||
endif()
|
||||
if (DEFINED ENV{NVTOOLSEXT_PATH})
|
||||
if(DEFINED ENV{NVTOOLSEXT_PATH})
|
||||
set(NVTOOLEXT_HOME $ENV{NVTOOLSEXT_PATH})
|
||||
file(TO_CMAKE_PATH ${NVTOOLEXT_HOME} NVTOOLEXT_HOME)
|
||||
endif()
|
||||
@ -782,10 +782,10 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../aten/src/ATen
|
||||
${CMAKE_BINARY_DIR}/aten/src)
|
||||
|
||||
IF (USE_TBB)
|
||||
if(USE_TBB)
|
||||
list(APPEND ATen_CPU_INCLUDE ${TBB_ROOT_DIR}/include)
|
||||
target_link_libraries(torch_cpu PUBLIC tbb)
|
||||
ENDIF()
|
||||
endif()
|
||||
|
||||
|
||||
target_include_directories(torch_cpu PRIVATE ${ATen_CPU_INCLUDE})
|
||||
@ -804,22 +804,22 @@ ENDIF()
|
||||
DESTINATION ${TORCH_INSTALL_INCLUDE_DIR}/torch)
|
||||
|
||||
|
||||
if (BUILD_TEST AND NOT USE_ROCM)
|
||||
if(BUILD_TEST AND NOT USE_ROCM)
|
||||
add_subdirectory(${TORCH_ROOT}/test/cpp/jit ${CMAKE_BINARY_DIR}/test_jit)
|
||||
add_subdirectory(${TORCH_ROOT}/test/cpp/tensorexpr ${CMAKE_BINARY_DIR}/test_tensorexpr)
|
||||
if (USE_DISTRIBUTED)
|
||||
if(USE_DISTRIBUTED)
|
||||
add_subdirectory(${TORCH_ROOT}/test/cpp/rpc ${CMAKE_BINARY_DIR}/test_cpp_rpc)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (BUILD_TEST AND NOT NO_API)
|
||||
if(BUILD_TEST AND NOT NO_API)
|
||||
add_subdirectory(${TORCH_ROOT}/test/cpp/api ${CMAKE_BINARY_DIR}/test_api)
|
||||
add_subdirectory(${TORCH_ROOT}/test/cpp/dist_autograd ${CMAKE_BINARY_DIR}/dist_autograd)
|
||||
endif()
|
||||
|
||||
# XXX This ABI check cannot be run with arm-linux-androideabi-g++
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
if (DEFINED GLIBCXX_USE_CXX11_ABI)
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||
if(DEFINED GLIBCXX_USE_CXX11_ABI)
|
||||
message(STATUS "_GLIBCXX_USE_CXX11_ABI is already defined as a cmake variable")
|
||||
else()
|
||||
message(STATUS "${CMAKE_CXX_COMPILER} ${TORCH_SRC_DIR}/abi-check.cpp -o ${CMAKE_BINARY_DIR}/abi-check")
|
||||
@ -830,14 +830,14 @@ ENDIF()
|
||||
"-o"
|
||||
"${CMAKE_BINARY_DIR}/abi-check"
|
||||
RESULT_VARIABLE ABI_CHECK_COMPILE_RESULT)
|
||||
if (ABI_CHECK_COMPILE_RESULT)
|
||||
if(ABI_CHECK_COMPILE_RESULT)
|
||||
message(FATAL_ERROR "Could not compile ABI Check: ${ABI_CHECK_COMPILE_RESULT}")
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_BINARY_DIR}/abi-check"
|
||||
RESULT_VARIABLE ABI_CHECK_RESULT
|
||||
OUTPUT_VARIABLE GLIBCXX_USE_CXX11_ABI)
|
||||
if (ABI_CHECK_RESULT)
|
||||
if(ABI_CHECK_RESULT)
|
||||
message(WARNING "Could not run ABI Check: ${ABI_CHECK_RESULT}")
|
||||
endif()
|
||||
endif()
|
||||
@ -858,8 +858,8 @@ ENDIF()
|
||||
${PROJECT_BINARY_DIR}/TorchConfig.cmake
|
||||
DESTINATION share/cmake/Torch)
|
||||
|
||||
if (USE_DISTRIBUTED)
|
||||
if (NOT MSVC)
|
||||
if(USE_DISTRIBUTED)
|
||||
if(NOT MSVC)
|
||||
add_subdirectory(${TORCH_SRC_DIR}/lib/c10d lib_c10d)
|
||||
endif()
|
||||
endif()
|
||||
@ -879,7 +879,7 @@ endif()
|
||||
|
||||
|
||||
|
||||
if (NOT NO_API)
|
||||
if(NOT NO_API)
|
||||
target_include_directories(torch_cpu PUBLIC
|
||||
$<BUILD_INTERFACE:${TORCH_SRC_DIR}/csrc/api>
|
||||
$<BUILD_INTERFACE:${TORCH_SRC_DIR}/csrc/api/include>)
|
||||
@ -927,23 +927,23 @@ endif()
|
||||
|
||||
# Pass USE_DISTRIBUTED to torch_cpu, as some codes in jit/pickler.cpp and
|
||||
# jit/unpickler.cpp need to be compiled only when USE_DISTRIBUTED is set
|
||||
if (USE_DISTRIBUTED)
|
||||
if(USE_DISTRIBUTED)
|
||||
target_compile_definitions(torch_cpu PRIVATE
|
||||
USE_DISTRIBUTED
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NOT INTERN_BUILD_MOBILE OR BUILD_CAFFE2_MOBILE)
|
||||
if(NOT INTERN_BUILD_MOBILE OR BUILD_CAFFE2_MOBILE)
|
||||
caffe2_interface_library(caffe2_protos caffe2_protos_whole)
|
||||
target_link_libraries(torch_cpu PRIVATE caffe2_protos_whole)
|
||||
if (${CAFFE2_LINK_LOCAL_PROTOBUF})
|
||||
if(${CAFFE2_LINK_LOCAL_PROTOBUF})
|
||||
target_link_libraries(torch_cpu INTERFACE protobuf::libprotobuf)
|
||||
else()
|
||||
target_link_libraries(torch_cpu PUBLIC protobuf::libprotobuf)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (USE_OPENMP AND OPENMP_FOUND)
|
||||
if(USE_OPENMP AND OPENMP_FOUND)
|
||||
message(STATUS "Caffe2 is compiling with OpenMP. \n"
|
||||
"OpenMP CXX_FLAGS: ${OpenMP_CXX_FLAGS}. \n"
|
||||
"OpenMP libraries: ${OpenMP_CXX_LIBRARIES}.")
|
||||
@ -977,19 +977,19 @@ endif()
|
||||
# OMP - OpenMP for intra-op, native thread pool for inter-op parallelism
|
||||
# NATIVE - using native thread pool for intra- and inter-op parallelism
|
||||
# TBB - using TBB for intra- and native thread pool for inter-op parallelism
|
||||
if (INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
|
||||
if(INTERN_BUILD_MOBILE AND NOT BUILD_CAFFE2_MOBILE)
|
||||
set(ATEN_THREADING "NATIVE" CACHE STRING "ATen parallel backend")
|
||||
else()
|
||||
set(ATEN_THREADING "OMP" CACHE STRING "ATen parallel backend")
|
||||
endif()
|
||||
|
||||
message(STATUS "Using ATen parallel backend: ${ATEN_THREADING}")
|
||||
if ("${ATEN_THREADING}" STREQUAL "OMP")
|
||||
if("${ATEN_THREADING}" STREQUAL "OMP")
|
||||
target_compile_definitions(torch_cpu PUBLIC "-DAT_PARALLEL_OPENMP=1")
|
||||
elseif ("${ATEN_THREADING}" STREQUAL "NATIVE")
|
||||
elseif("${ATEN_THREADING}" STREQUAL "NATIVE")
|
||||
target_compile_definitions(torch_cpu PUBLIC "-DAT_PARALLEL_NATIVE=1")
|
||||
elseif ("${ATEN_THREADING}" STREQUAL "TBB")
|
||||
if (NOT USE_TBB)
|
||||
elseif("${ATEN_THREADING}" STREQUAL "TBB")
|
||||
if(NOT USE_TBB)
|
||||
message(FATAL_ERROR "Using TBB backend but USE_TBB is off")
|
||||
endif()
|
||||
target_compile_definitions(torch_cpu PUBLIC "-DAT_PARALLEL_NATIVE_TBB=1")
|
||||
@ -998,11 +998,11 @@ else()
|
||||
endif()
|
||||
set(EXPERIMENTAL_SINGLE_THREAD_POOL "0" CACHE STRING
|
||||
"Experimental option to use a single thread pool for inter- and intra-op parallelism")
|
||||
if ("${EXPERIMENTAL_SINGLE_THREAD_POOL}")
|
||||
if("${EXPERIMENTAL_SINGLE_THREAD_POOL}")
|
||||
target_compile_definitions(torch_cpu PUBLIC "-DAT_EXPERIMENTAL_SINGLE_THREAD_POOL=1")
|
||||
endif()
|
||||
|
||||
if (MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
# Note [Supporting both static and dynamic libraries on Windows]
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# A Windows library may be distributed as either a static or dynamic
|
||||
@ -1071,7 +1071,7 @@ if (MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
# as the latter is not respected by nvcc
|
||||
target_compile_definitions(torch_cpu PUBLIC "AT_CORE_STATIC_WINDOWS=1")
|
||||
endif()
|
||||
if (MSVC AND BUILD_SHARED_LIBS)
|
||||
if(MSVC AND BUILD_SHARED_LIBS)
|
||||
# ONNX is linked statically and needs to be exported from this library
|
||||
# to be used externally. Make sure that references match the export.
|
||||
target_compile_options(torch_cpu PRIVATE "-DONNX_BUILD_MAIN_LIB")
|
||||
@ -1079,18 +1079,18 @@ endif()
|
||||
|
||||
caffe2_interface_library(torch_cpu torch_cpu_library)
|
||||
|
||||
if (USE_CUDA)
|
||||
if(USE_CUDA)
|
||||
caffe2_interface_library(torch_cuda torch_cuda_library)
|
||||
elseif (USE_ROCM)
|
||||
elseif(USE_ROCM)
|
||||
caffe2_interface_library(torch_hip torch_hip_library)
|
||||
endif()
|
||||
|
||||
caffe2_interface_library(torch torch_library)
|
||||
|
||||
install(TARGETS torch_cpu torch_cpu_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR}")
|
||||
if (USE_CUDA)
|
||||
if(USE_CUDA)
|
||||
install(TARGETS torch_cuda torch_cuda_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR}")
|
||||
elseif (USE_ROCM)
|
||||
elseif(USE_ROCM)
|
||||
install(TARGETS torch_hip torch_hip_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR}")
|
||||
endif()
|
||||
install(TARGETS torch torch_library EXPORT Caffe2Targets DESTINATION "${TORCH_INSTALL_LIB_DIR}")
|
||||
@ -1103,12 +1103,12 @@ elseif(USE_ROCM)
|
||||
endif()
|
||||
|
||||
list(APPEND Caffe2_MAIN_LIBS torch_library)
|
||||
if (USE_TBB)
|
||||
if(USE_TBB)
|
||||
list(APPEND Caffe2_MAIN_LIBS tbb)
|
||||
endif()
|
||||
|
||||
# Install PDB files for MSVC builds
|
||||
if (MSVC AND BUILD_SHARED_LIBS)
|
||||
if(MSVC AND BUILD_SHARED_LIBS)
|
||||
install(FILES $<TARGET_PDB_FILE:torch_cpu> DESTINATION "${TORCH_INSTALL_LIB_DIR}" OPTIONAL)
|
||||
if(USE_CUDA)
|
||||
install(FILES $<TARGET_PDB_FILE:torch_cuda> DESTINATION "${TORCH_INSTALL_LIB_DIR}" OPTIONAL)
|
||||
@ -1148,10 +1148,10 @@ endif()
|
||||
# namespaces, so libtorch is loaded with all its dependencies in a local scope.
|
||||
# That usually leads to missing symbol errors at run-time, so to avoid a situation like
|
||||
# this we have to preload those libs in a global namespace.
|
||||
if (BUILD_SHARED_LIBS)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
add_library(torch_global_deps SHARED ${TORCH_SRC_DIR}/csrc/empty.c)
|
||||
set_target_properties(torch_global_deps PROPERTIES LINKER_LANGUAGE C)
|
||||
if (USE_MPI)
|
||||
if(USE_MPI)
|
||||
target_link_libraries(torch_global_deps ${MPI_CXX_LIBRARIES})
|
||||
endif()
|
||||
target_link_libraries(torch_global_deps ${MKL_LIBRARIES})
|
||||
@ -1159,7 +1159,7 @@ if (BUILD_SHARED_LIBS)
|
||||
# cases we load these libraries with ctypes, and if they weren't opened
|
||||
# with RTLD_GLOBAL, we'll do the "normal" search process again (and
|
||||
# not find them, because they're usually in non-standard locations)
|
||||
if (USE_CUDA)
|
||||
if(USE_CUDA)
|
||||
target_link_libraries(torch_global_deps ${TORCH_CUDA_LIBRARIES})
|
||||
target_link_libraries(torch_global_deps ${Caffe2_PUBLIC_CUDA_DEPENDENCY_LIBS})
|
||||
target_link_libraries(torch_global_deps torch::cudart)
|
||||
@ -1202,7 +1202,7 @@ if(USE_ROCM)
|
||||
endif()
|
||||
|
||||
# ---[ Test binaries.
|
||||
if (BUILD_TEST)
|
||||
if(BUILD_TEST)
|
||||
foreach(test_src ${Caffe2_CPU_TEST_SRCS})
|
||||
get_filename_component(test_name ${test_src} NAME_WE)
|
||||
add_executable(${test_name} "${test_src}")
|
||||
@ -1210,16 +1210,16 @@ if (BUILD_TEST)
|
||||
target_include_directories(${test_name} PRIVATE $<INSTALL_INTERFACE:include>)
|
||||
target_include_directories(${test_name} PRIVATE ${Caffe2_CPU_INCLUDE})
|
||||
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
|
||||
if (INSTALL_TEST)
|
||||
if(INSTALL_TEST)
|
||||
install(TARGETS ${test_name} DESTINATION test)
|
||||
# Install PDB files for MSVC builds
|
||||
if (MSVC AND BUILD_SHARED_LIBS)
|
||||
if(MSVC AND BUILD_SHARED_LIBS)
|
||||
install(FILES $<TARGET_PDB_FILE:${test_name}> DESTINATION test OPTIONAL)
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if (USE_CUDA)
|
||||
if(USE_CUDA)
|
||||
foreach(test_src ${Caffe2_GPU_TEST_SRCS})
|
||||
get_filename_component(test_name ${test_src} NAME_WE)
|
||||
cuda_add_executable(${test_name} "${test_src}")
|
||||
@ -1227,10 +1227,10 @@ if (BUILD_TEST)
|
||||
target_include_directories(${test_name} PRIVATE $<INSTALL_INTERFACE:include>)
|
||||
target_include_directories(${test_name} PRIVATE ${Caffe2_CPU_INCLUDE})
|
||||
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
|
||||
if (INSTALL_TEST)
|
||||
if(INSTALL_TEST)
|
||||
install(TARGETS ${test_name} DESTINATION test)
|
||||
# Install PDB files for MSVC builds
|
||||
if (MSVC AND BUILD_SHARED_LIBS)
|
||||
if(MSVC AND BUILD_SHARED_LIBS)
|
||||
install(FILES $<TARGET_PDB_FILE:${test_name}> DESTINATION test OPTIONAL)
|
||||
endif()
|
||||
endif()
|
||||
@ -1246,16 +1246,16 @@ if (BUILD_TEST)
|
||||
target_include_directories(${test_name} PRIVATE ${Caffe2_CPU_INCLUDE} ${Caffe2_HIP_INCLUDE})
|
||||
target_compile_options(${test_name} PRIVATE ${HIP_CXX_FLAGS})
|
||||
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
|
||||
if (INSTALL_TEST)
|
||||
if(INSTALL_TEST)
|
||||
install(TARGETS ${test_name} DESTINATION test)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# For special tests that explicitly uses dependencies, we add them here
|
||||
if (USE_MPI)
|
||||
if(USE_MPI)
|
||||
target_link_libraries(mpi_test ${MPI_CXX_LIBRARIES})
|
||||
if (USE_CUDA)
|
||||
if(USE_CUDA)
|
||||
target_link_libraries(mpi_gpu_test ${MPI_CXX_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
@ -1267,7 +1267,7 @@ endif()
|
||||
# rebuild step. The long-term fix should be to clean up these rules so they
|
||||
# only rerun when needed.
|
||||
|
||||
if (BUILD_PYTHON)
|
||||
if(BUILD_PYTHON)
|
||||
# Python site-packages
|
||||
# Get canonical directory for python site packages (relative to install
|
||||
# location). It varies from system to system.
|
||||
@ -1293,7 +1293,7 @@ if (BUILD_PYTHON)
|
||||
print(ext_suffix if ext_suffix else '')
|
||||
")
|
||||
if("${PY_EXT_SUFFIX}" STREQUAL "")
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
set(PY_EXT_SUFFIX ".pyd")
|
||||
else()
|
||||
set(PY_EXT_SUFFIX ".so")
|
||||
@ -1318,13 +1318,13 @@ if (BUILD_PYTHON)
|
||||
# `caffe2_pybind11_state_*` targets because paths to required libraries may
|
||||
# need to be found there (e.g., specifying path to `libiomp5` with `LDFLAGS`).
|
||||
set(_caffe2_pybind11_state_linker_flags "${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
if (APPLE)
|
||||
if(APPLE)
|
||||
set(_caffe2_pybind11_state_linker_flags "${_caffe2_pybind11_state_linker_flags} -undefined dynamic_lookup")
|
||||
endif()
|
||||
|
||||
# ---[ Python.
|
||||
add_library(caffe2_pybind11_state MODULE ${Caffe2_CPU_PYTHON_SRCS})
|
||||
if (NOT MSVC)
|
||||
if(NOT MSVC)
|
||||
set_target_properties(caffe2_pybind11_state PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
|
||||
endif()
|
||||
set_target_properties(caffe2_pybind11_state PROPERTIES PREFIX "" DEBUG_POSTFIX "")
|
||||
@ -1335,7 +1335,7 @@ if (BUILD_PYTHON)
|
||||
|
||||
target_link_libraries(
|
||||
caffe2_pybind11_state torch_library)
|
||||
if (WIN32)
|
||||
if(WIN32)
|
||||
target_link_libraries(caffe2_pybind11_state ${PYTHON_LIBRARIES})
|
||||
target_link_libraries(caffe2_pybind11_state onnx_proto)
|
||||
endif(WIN32)
|
||||
@ -1346,14 +1346,14 @@ if (BUILD_PYTHON)
|
||||
caffe2_pybind11_state PROPERTIES LIBRARY_OUTPUT_DIRECTORY
|
||||
${CMAKE_BINARY_DIR}/caffe2/python)
|
||||
install(TARGETS caffe2_pybind11_state DESTINATION "${PYTHON_LIB_REL_PATH}/caffe2/python")
|
||||
if (MSVC AND BUILD_SHARED_LIBS)
|
||||
if(MSVC AND BUILD_SHARED_LIBS)
|
||||
install(FILES $<TARGET_PDB_FILE:caffe2_pybind11_state> DESTINATION "${PYTHON_LIB_REL_PATH}/caffe2/python" OPTIONAL)
|
||||
endif()
|
||||
set_target_properties(caffe2_pybind11_state PROPERTIES INSTALL_RPATH "${caffe2_pybind11_rpath}")
|
||||
|
||||
if(USE_CUDA)
|
||||
add_library(caffe2_pybind11_state_gpu MODULE ${Caffe2_GPU_PYTHON_SRCS})
|
||||
if (NOT MSVC)
|
||||
if(NOT MSVC)
|
||||
set_target_properties(caffe2_pybind11_state_gpu PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
|
||||
endif()
|
||||
set_target_properties(caffe2_pybind11_state_gpu PROPERTIES PREFIX "" DEBUG_POSTFIX "")
|
||||
@ -1362,7 +1362,7 @@ if (BUILD_PYTHON)
|
||||
target_include_directories(caffe2_pybind11_state_gpu PRIVATE $<INSTALL_INTERFACE:include>)
|
||||
target_include_directories(caffe2_pybind11_state_gpu PRIVATE ${Caffe2_CPU_INCLUDE})
|
||||
target_link_libraries(caffe2_pybind11_state_gpu torch_library)
|
||||
if (WIN32)
|
||||
if(WIN32)
|
||||
target_link_libraries(caffe2_pybind11_state_gpu ${PYTHON_LIBRARIES})
|
||||
target_link_libraries(caffe2_pybind11_state_gpu onnx_proto)
|
||||
endif(WIN32)
|
||||
@ -1372,7 +1372,7 @@ if (BUILD_PYTHON)
|
||||
caffe2_pybind11_state_gpu PROPERTIES LIBRARY_OUTPUT_DIRECTORY
|
||||
${CMAKE_BINARY_DIR}/caffe2/python)
|
||||
install(TARGETS caffe2_pybind11_state_gpu DESTINATION "${PYTHON_LIB_REL_PATH}/caffe2/python")
|
||||
if (MSVC AND BUILD_SHARED_LIBS)
|
||||
if(MSVC AND BUILD_SHARED_LIBS)
|
||||
install(FILES $<TARGET_PDB_FILE:caffe2_pybind11_state_gpu> DESTINATION "${PYTHON_LIB_REL_PATH}/caffe2/python" OPTIONAL)
|
||||
endif()
|
||||
set_target_properties(caffe2_pybind11_state_gpu PROPERTIES INSTALL_RPATH "${caffe2_pybind11_rpath}")
|
||||
@ -1380,7 +1380,7 @@ if (BUILD_PYTHON)
|
||||
|
||||
if(USE_ROCM)
|
||||
add_library(caffe2_pybind11_state_hip MODULE ${Caffe2_HIP_PYTHON_SRCS})
|
||||
if (NOT MSVC)
|
||||
if(NOT MSVC)
|
||||
target_compile_options(caffe2_pybind11_state_hip PRIVATE ${HIP_CXX_FLAGS} -fvisibility=hidden)
|
||||
endif()
|
||||
set_target_properties(caffe2_pybind11_state_hip PROPERTIES PREFIX "")
|
||||
@ -1389,7 +1389,7 @@ if (BUILD_PYTHON)
|
||||
target_include_directories(caffe2_pybind11_state_hip PRIVATE $<INSTALL_INTERFACE:include>)
|
||||
target_include_directories(caffe2_pybind11_state_hip PRIVATE ${Caffe2_CPU_INCLUDE} ${Caffe2_HIP_INCLUDE})
|
||||
target_link_libraries(caffe2_pybind11_state_hip torch_library)
|
||||
if (WIN32)
|
||||
if(WIN32)
|
||||
target_link_libraries(caffe2_pybind11_state_hip ${PYTHON_LIBRARIES})
|
||||
endif(WIN32)
|
||||
|
||||
@ -1401,7 +1401,7 @@ if (BUILD_PYTHON)
|
||||
set_target_properties(caffe2_pybind11_state_hip PROPERTIES INSTALL_RPATH "${caffe2_pybind11_rpath}")
|
||||
endif()
|
||||
|
||||
if (MSVC AND CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
if(MSVC AND CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
# If we are building under windows, we will copy the file from
|
||||
# build/caffe2/python/{Debug,Release}/caffe2_pybind11_state.pyd
|
||||
# to its parent folder so that we can do in-build execution.
|
||||
@ -1412,7 +1412,7 @@ if (BUILD_PYTHON)
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
$<TARGET_FILE:caffe2_pybind11_state>
|
||||
${CMAKE_BINARY_DIR}/caffe2/python)
|
||||
if (USE_CUDA)
|
||||
if(USE_CUDA)
|
||||
add_dependencies(windows_python_copy_lib caffe2_pybind11_state_gpu)
|
||||
add_custom_command(
|
||||
TARGET windows_python_copy_lib POST_BUILD
|
||||
@ -1420,7 +1420,7 @@ if (BUILD_PYTHON)
|
||||
$<TARGET_FILE:caffe2_pybind11_state_gpu>
|
||||
${CMAKE_BINARY_DIR}/caffe2/python)
|
||||
endif()
|
||||
if (USE_ROCM)
|
||||
if(USE_ROCM)
|
||||
add_dependencies(windows_python_copy_lib caffe2_pybind11_state_hip)
|
||||
add_custom_command(
|
||||
TARGET windows_python_copy_lib POST_BUILD
|
||||
|
@ -24,7 +24,7 @@ function (caffe2_print_configuration_summary)
|
||||
message(STATUS " USE_STATIC_DISPATCH : ${USE_STATIC_DISPATCH}")
|
||||
message(STATUS " BUILD_BINARY : ${BUILD_BINARY}")
|
||||
message(STATUS " BUILD_CUSTOM_PROTOBUF : ${BUILD_CUSTOM_PROTOBUF}")
|
||||
if (${CAFFE2_LINK_LOCAL_PROTOBUF})
|
||||
if(${CAFFE2_LINK_LOCAL_PROTOBUF})
|
||||
message(STATUS " Link local protobuf : ${CAFFE2_LINK_LOCAL_PROTOBUF}")
|
||||
else()
|
||||
message(STATUS " Protobuf compiler : ${PROTOBUF_PROTOC_EXECUTABLE}")
|
||||
@ -33,7 +33,7 @@ function (caffe2_print_configuration_summary)
|
||||
endif()
|
||||
message(STATUS " BUILD_DOCS : ${BUILD_DOCS}")
|
||||
message(STATUS " BUILD_PYTHON : ${BUILD_PYTHON}")
|
||||
if (${BUILD_PYTHON})
|
||||
if(${BUILD_PYTHON})
|
||||
message(STATUS " Python version : ${PYTHON_VERSION_STRING}")
|
||||
message(STATUS " Python executable : ${PYTHON_EXECUTABLE}")
|
||||
message(STATUS " Pythonlibs version : ${PYTHONLIBS_VERSION_STRING}")
|
||||
|
@ -17,7 +17,7 @@ endif(MSVC)
|
||||
target_link_libraries(test_jit PRIVATE ${JIT_TEST_DEPENDENCIES})
|
||||
target_include_directories(test_jit PRIVATE ${ATen_CPU_INCLUDE})
|
||||
|
||||
if (USE_CUDA)
|
||||
if(USE_CUDA)
|
||||
target_link_libraries(test_jit PRIVATE
|
||||
${CUDA_LIBRARIES}
|
||||
${CUDA_NVRTC_LIB}
|
||||
@ -25,7 +25,7 @@ if (USE_CUDA)
|
||||
${TORCH_CUDA_LIBRARIES})
|
||||
|
||||
target_compile_definitions(test_jit PRIVATE USE_CUDA)
|
||||
elseif (USE_ROCM)
|
||||
elseif(USE_ROCM)
|
||||
target_link_libraries(test_jit PRIVATE
|
||||
${ROCM_HIPRTC_LIB}
|
||||
${PYTORCH_HIP_HCC_LIBRARIES}
|
||||
@ -36,10 +36,10 @@ elseif (USE_ROCM)
|
||||
target_compile_definitions(test_jit PRIVATE USE_ROCM)
|
||||
endif()
|
||||
|
||||
if (INSTALL_TEST)
|
||||
if(INSTALL_TEST)
|
||||
install(TARGETS test_jit DESTINATION bin)
|
||||
# Install PDB files for MSVC builds
|
||||
if (MSVC AND BUILD_SHARED_LIBS)
|
||||
if(MSVC AND BUILD_SHARED_LIBS)
|
||||
install(FILES $<TARGET_PDB_FILE:test_jit> DESTINATION bin OPTIONAL)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -12,7 +12,7 @@ add_executable(test_tensorexpr
|
||||
target_link_libraries(test_tensorexpr PRIVATE torch gtest)
|
||||
target_include_directories(test_tensorexpr PRIVATE ${ATen_CPU_INCLUDE})
|
||||
|
||||
if (USE_CUDA)
|
||||
if(USE_CUDA)
|
||||
target_link_libraries(test_tensorexpr PRIVATE
|
||||
${CUDA_LIBRARIES}
|
||||
${CUDA_NVRTC_LIB}
|
||||
@ -20,7 +20,7 @@ if (USE_CUDA)
|
||||
${TORCH_CUDA_LIBRARIES})
|
||||
|
||||
target_compile_definitions(test_tensorexpr PRIVATE USE_CUDA)
|
||||
elseif (USE_ROCM)
|
||||
elseif(USE_ROCM)
|
||||
target_link_libraries(test_tensorexpr PRIVATE
|
||||
${ROCM_HIPRTC_LIB}
|
||||
${PYTORCH_HIP_HCC_LIBRARIES}
|
||||
@ -31,10 +31,10 @@ elseif (USE_ROCM)
|
||||
target_compile_definitions(test_tensorexpr PRIVATE USE_ROCM)
|
||||
endif()
|
||||
|
||||
if (INSTALL_TEST)
|
||||
if(INSTALL_TEST)
|
||||
install(TARGETS test_tensorexpr DESTINATION bin)
|
||||
# Install PDB files for MSVC builds
|
||||
if (MSVC AND BUILD_SHARED_LIBS)
|
||||
if(MSVC AND BUILD_SHARED_LIBS)
|
||||
install(FILES $<TARGET_PDB_FILE:test_tensorexpr> DESTINATION bin OPTIONAL)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This file used to build libtorch.so.
|
||||
# Now it only builds the Torch python bindings.
|
||||
|
||||
if (NOT CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
|
||||
if(NOT CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
|
||||
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
|
||||
project(torch CXX C)
|
||||
find_package(torch REQUIRED)
|
||||
@ -9,11 +9,11 @@ if (NOT CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
endif()
|
||||
|
||||
if (NOT BUILD_PYTHON)
|
||||
if(NOT BUILD_PYTHON)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if (USE_TBB)
|
||||
if(USE_TBB)
|
||||
include_directories(${TBB_ROOT_DIR}/include)
|
||||
endif()
|
||||
|
||||
@ -24,7 +24,7 @@ if(NOT TORCH_INSTALL_LIB_DIR)
|
||||
set(TORCH_INSTALL_LIB_DIR lib)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
set(LIBSHM_SUBDIR libshm_windows)
|
||||
else()
|
||||
set(LIBSHM_SUBDIR libshm)
|
||||
@ -114,7 +114,7 @@ set(TORCH_PYTHON_SRCS
|
||||
|
||||
# NB: This has to match the condition under which the JIT test directory
|
||||
# is included (at the time of writing that's in caffe2/CMakeLists.txt).
|
||||
if (BUILD_TEST AND NOT USE_ROCM)
|
||||
if(BUILD_TEST AND NOT USE_ROCM)
|
||||
add_definitions(-DBUILDING_TESTS)
|
||||
list(APPEND TORCH_PYTHON_SRCS
|
||||
${TORCH_ROOT}/test/cpp/jit/torch_python_test.cpp
|
||||
@ -157,16 +157,16 @@ set(TORCH_PYTHON_COMPILE_OPTIONS)
|
||||
|
||||
set(TORCH_PYTHON_LINK_FLAGS "")
|
||||
|
||||
if (MSVC)
|
||||
if(MSVC)
|
||||
string(APPEND TORCH_PYTHON_LINK_FLAGS " /NODEFAULTLIB:LIBCMT.LIB")
|
||||
list(APPEND TORCH_PYTHON_LINK_LIBRARIES ${PYTHON_LIBRARIES})
|
||||
if (BUILD_TEST)
|
||||
if(BUILD_TEST)
|
||||
list(APPEND TORCH_PYTHON_LINK_LIBRARIES onnx_library)
|
||||
endif(BUILD_TEST)
|
||||
if (NOT ${CMAKE_BUILD_TYPE} MATCHES "Release")
|
||||
if(NOT ${CMAKE_BUILD_TYPE} MATCHES "Release")
|
||||
string(APPEND TORCH_PYTHON_LINK_FLAGS " /DEBUG:FULL")
|
||||
endif()
|
||||
elseif (APPLE)
|
||||
elseif(APPLE)
|
||||
string(APPEND TORCH_PYTHON_LINK_FLAGS " -undefined dynamic_lookup")
|
||||
else()
|
||||
list(APPEND TORCH_PYTHON_COMPILE_OPTIONS
|
||||
@ -175,7 +175,7 @@ else()
|
||||
-Wno-strict-aliasing)
|
||||
endif()
|
||||
|
||||
if (USE_CUDA)
|
||||
if(USE_CUDA)
|
||||
list(APPEND TORCH_PYTHON_SRCS
|
||||
${TORCH_SRC_DIR}/csrc/cuda/Module.cpp
|
||||
${TORCH_SRC_DIR}/csrc/cuda/Storage.cpp
|
||||
@ -202,7 +202,7 @@ if (USE_CUDA)
|
||||
|
||||
endif()
|
||||
|
||||
if (USE_CUDNN)
|
||||
if(USE_CUDNN)
|
||||
list(APPEND TORCH_PYTHON_COMPILE_DEFINITIONS USE_CUDNN)
|
||||
|
||||
# NOTE: these are at the front, in case there's another cuDNN in
|
||||
@ -217,11 +217,11 @@ if (USE_CUDNN)
|
||||
)
|
||||
endif()
|
||||
|
||||
if (USE_NUMPY)
|
||||
if(USE_NUMPY)
|
||||
list(APPEND TORCH_PYTHON_COMPILE_DEFINITIONS USE_NUMPY)
|
||||
endif()
|
||||
|
||||
if (USE_ROCM)
|
||||
if(USE_ROCM)
|
||||
list(APPEND TORCH_PYTHON_SRCS
|
||||
${TORCH_SRC_DIR}/csrc/cuda/Module.cpp
|
||||
${TORCH_SRC_DIR}/csrc/cuda/Storage.cpp
|
||||
@ -244,9 +244,9 @@ if (USE_ROCM)
|
||||
list(APPEND TORCH_PYTHON_INCLUDE_DIRECTORIES ${roctracer_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if (USE_DISTRIBUTED)
|
||||
if(USE_DISTRIBUTED)
|
||||
list(APPEND TORCH_PYTHON_COMPILE_DEFINITIONS USE_DISTRIBUTED)
|
||||
if (NOT MSVC)
|
||||
if(NOT MSVC)
|
||||
list(APPEND TORCH_PYTHON_SRCS
|
||||
${TORCH_SRC_DIR}/csrc/distributed/autograd/init.cpp
|
||||
${TORCH_SRC_DIR}/csrc/distributed/c10d/comm.cpp
|
||||
@ -266,13 +266,13 @@ if (USE_DISTRIBUTED)
|
||||
)
|
||||
list(APPEND TORCH_PYTHON_LINK_LIBRARIES c10d)
|
||||
list(APPEND TORCH_PYTHON_COMPILE_DEFINITIONS USE_C10D)
|
||||
if (USE_CUDA OR USE_ROCM)
|
||||
if(USE_CUDA OR USE_ROCM)
|
||||
list(APPEND TORCH_PYTHON_SRCS ${TORCH_SRC_DIR}/csrc/distributed/c10d/ddp.cpp)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (USE_NCCL)
|
||||
if(USE_NCCL)
|
||||
list(APPEND TORCH_PYTHON_SRCS
|
||||
${TORCH_SRC_DIR}/csrc/cuda/python_nccl.cpp)
|
||||
list(APPEND TORCH_PYTHON_COMPILE_DEFINITIONS USE_NCCL)
|
||||
@ -403,7 +403,7 @@ target_compile_options(torch_python PRIVATE ${TORCH_PYTHON_COMPILE_OPTIONS})
|
||||
target_include_directories(torch_python PUBLIC ${TORCH_PYTHON_INCLUDE_DIRECTORIES})
|
||||
|
||||
|
||||
if (NOT TORCH_PYTHON_LINK_FLAGS STREQUAL "")
|
||||
if(NOT TORCH_PYTHON_LINK_FLAGS STREQUAL "")
|
||||
set_target_properties(torch_python PROPERTIES LINK_FLAGS ${TORCH_PYTHON_LINK_FLAGS})
|
||||
endif()
|
||||
|
||||
|
Reference in New Issue
Block a user