python-torch/0001-Prepare-pytorch-cmake-for-fedora.patch
Tom Rix 48192fa108 Initial import
Signed-off-by: Tom Rix <trix@redhat.com>
2023-12-02 15:19:42 -05:00

169 lines
6.7 KiB
Diff

From 24cf0294a67d89ad70367940eea872162b44482c Mon Sep 17 00:00:00 2001
From: Tom Rix <trix@redhat.com>
Date: Sat, 23 Sep 2023 10:18:52 -0700
Subject: [PATCH] Prepare pytorch cmake for fedora
Use the system fmt
Remove foxi use
Remove warnings/errors for clang 17
fxdiv is not a library
build type is RelWithDebInfo
use system pthreadpool
Signed-off-by: Tom Rix <trix@redhat.com>
---
CMakeLists.txt | 6 +++---
.../native/quantized/cpu/qnnpack/CMakeLists.txt | 3 ---
c10/CMakeLists.txt | 2 +-
caffe2/CMakeLists.txt | 6 +-----
cmake/Dependencies.cmake | 16 +---------------
test/cpp/tensorexpr/CMakeLists.txt | 2 +-
torch/CMakeLists.txt | 2 +-
7 files changed, 8 insertions(+), 29 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3a48eaf4e2..902ee70fd1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -682,7 +682,7 @@ set(CAFFE2_ALLOWLIST "" CACHE STRING "A allowlist file of files that one should
# Set default build type
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Build type not set - defaulting to Release")
- set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build from: Debug Release RelWithDebInfo MinSizeRel Coverage." FORCE)
+ set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build from: Debug Release RelWithDebInfo MinSizeRel Coverage." FORCE)
endif()
# The below means we are cross compiling for arm64 or x86_64 on MacOSX
@@ -917,8 +917,8 @@ if(NOT MSVC)
string(APPEND CMAKE_LINKER_FLAGS_DEBUG " -fno-omit-frame-pointer -O0")
append_cxx_flag_if_supported("-fno-math-errno" CMAKE_CXX_FLAGS)
append_cxx_flag_if_supported("-fno-trapping-math" CMAKE_CXX_FLAGS)
- append_cxx_flag_if_supported("-Werror=format" CMAKE_CXX_FLAGS)
- append_cxx_flag_if_supported("-Werror=cast-function-type" CMAKE_CXX_FLAGS)
+# append_cxx_flag_if_supported("-Werror=format" CMAKE_CXX_FLAGS)
+# append_cxx_flag_if_supported("-Werror=cast-function-type" CMAKE_CXX_FLAGS)
else()
# skip unwanted includes from windows.h
add_compile_definitions(WIN32_LEAN_AND_MEAN)
diff --git a/aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt b/aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt
index fd6b7ff551..218c8e9b2a 100644
--- a/aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt
+++ b/aten/src/ATen/native/quantized/cpu/qnnpack/CMakeLists.txt
@@ -393,10 +393,7 @@ elseif(NOT TARGET fxdiv AND USE_SYSTEM_FXDIV)
if(NOT FXDIV_HDR)
message(FATAL_ERROR "Cannot find fxdiv")
endif()
- add_library(fxdiv STATIC "${FXDIV_HDR}")
- set_property(TARGET fxdiv PROPERTY LINKER_LANGUAGE C)
endif()
-target_link_libraries(pytorch_qnnpack PRIVATE fxdiv)
# ---[ Configure psimd
if(NOT TARGET psimd AND NOT USE_SYSTEM_PSIMD)
diff --git a/c10/CMakeLists.txt b/c10/CMakeLists.txt
index feebad7cbb..7c029cd88d 100644
--- a/c10/CMakeLists.txt
+++ b/c10/CMakeLists.txt
@@ -87,7 +87,7 @@ endif()
if(${USE_GLOG})
target_link_libraries(c10 PUBLIC glog::glog)
endif()
-target_link_libraries(c10 PRIVATE fmt::fmt-header-only)
+target_link_libraries(c10 PRIVATE fmt)
find_package(Backtrace)
if(Backtrace_FOUND)
diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt
index 74d0d55719..b975d388a7 100644
--- a/caffe2/CMakeLists.txt
+++ b/caffe2/CMakeLists.txt
@@ -107,7 +107,7 @@ endif()
# Note: the folders that are being commented out have not been properly
# addressed yet.
-if(NOT MSVC AND USE_XNNPACK)
+if(NOT MSVC AND USE_XNNPACK AND NOT USE_SYSTEM_FXDIV)
if(NOT TARGET fxdiv)
set(FXDIV_BUILD_TESTS OFF CACHE BOOL "")
set(FXDIV_BUILD_BENCHMARKS OFF CACHE BOOL "")
@@ -1022,10 +1022,6 @@ elseif(USE_CUDA)
endif()
endif()
-if(NOT MSVC AND USE_XNNPACK)
- TARGET_LINK_LIBRARIES(torch_cpu PRIVATE fxdiv)
-endif()
-
# ==========================================================
# formerly-libtorch flags
# ==========================================================
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index c3abce52e4..21b40f3a88 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -1555,7 +1555,6 @@ if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
set_target_properties(onnx_proto PROPERTIES CXX_STANDARD 17)
endif()
endif()
- add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/foxi EXCLUDE_FROM_ALL)
add_definitions(-DONNX_NAMESPACE=${ONNX_NAMESPACE})
if(NOT USE_SYSTEM_ONNX)
@@ -1588,8 +1587,6 @@ if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
message("-- Found onnx: ${ONNX_LIBRARY} ${ONNX_PROTO_LIBRARY}")
list(APPEND Caffe2_DEPENDENCY_LIBS onnx_proto onnx)
endif()
- include_directories(${FOXI_INCLUDE_DIRS})
- list(APPEND Caffe2_DEPENDENCY_LIBS foxi_loader)
# Recover the build shared libs option.
set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS})
endif()
@@ -1834,18 +1831,7 @@ endif()
#
set(TEMP_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libs" FORCE)
-add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/fmt)
-
-# Disable compiler feature checks for `fmt`.
-#
-# CMake compiles a little program to check compiler features. Some of our build
-# configurations (notably the mobile build analyzer) will populate
-# CMAKE_CXX_FLAGS in ways that break feature checks. Since we already know
-# `fmt` is compatible with a superset of the compilers that PyTorch is, it
-# shouldn't be too bad to just disable the checks.
-set_target_properties(fmt-header-only PROPERTIES INTERFACE_COMPILE_FEATURES "")
-
-list(APPEND Caffe2_DEPENDENCY_LIBS fmt::fmt-header-only)
+list(APPEND Caffe2_DEPENDENCY_LIBS fmt)
set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
# ---[ Kineto
diff --git a/test/cpp/tensorexpr/CMakeLists.txt b/test/cpp/tensorexpr/CMakeLists.txt
index 7dff70630d..90b1003591 100644
--- a/test/cpp/tensorexpr/CMakeLists.txt
+++ b/test/cpp/tensorexpr/CMakeLists.txt
@@ -54,7 +54,7 @@ target_include_directories(tutorial_tensorexpr PRIVATE ${ATen_CPU_INCLUDE})
# pthreadpool header. For some build environment we need add the dependency
# explicitly.
if(USE_PTHREADPOOL)
- target_link_libraries(test_tensorexpr PRIVATE pthreadpool_interface)
+ target_link_libraries(test_tensorexpr PRIVATE pthreadpool)
endif()
if(USE_CUDA)
target_link_libraries(test_tensorexpr PRIVATE
diff --git a/torch/CMakeLists.txt b/torch/CMakeLists.txt
index 62ee4c12a9..8d5375f320 100644
--- a/torch/CMakeLists.txt
+++ b/torch/CMakeLists.txt
@@ -84,7 +84,7 @@ set(TORCH_PYTHON_LINK_LIBRARIES
python::python
pybind::pybind11
shm
- fmt::fmt-header-only
+ fmt
ATEN_CPU_FILES_GEN_LIB)
if(USE_ASAN AND TARGET Sanitizer::address)
--
2.42.1