Skip to content

Commit

Permalink
[libtorch] more cmake,source patches
Browse files Browse the repository at this point in the history
  • Loading branch information
luncliff committed Oct 25, 2024
1 parent 6e73401 commit e2a8a8f
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 11 deletions.
26 changes: 26 additions & 0 deletions ports/libtorch/fix-cmake.patch
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,29 @@ index 257c0bd..4788bcf 100644

if(NOT MSVC)
set(CMAKE_C_FLAGS_DEBUG ${OLD_CMAKE_C_FLAGS_DEBUG})
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8d3253c..7502685 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -781,7 +781,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()

# The below means we are cross compiling for arm64 or x86_64 on MacOSX
-if(NOT IOS
+if(BUILD_CUSTOM_PROTOBUF AND NOT IOS
AND CMAKE_SYSTEM_NAME STREQUAL "Darwin"
AND CMAKE_OSX_ARCHITECTURES MATCHES "^(x86_64|arm64)$")
set(CROSS_COMPILING_MACOSX TRUE)
diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt
index b5aaeba..d55ffe7 100644
--- a/caffe2/CMakeLists.txt
+++ b/caffe2/CMakeLists.txt
@@ -88,7 +88,7 @@ endif()
# addressed yet.

if(NOT MSVC AND USE_XNNPACK)
- if(NOT TARGET fxdiv)
+ if(NOT TARGET fxdiv AND NOT USE_SYSTEM_FXDIV)
set(FXDIV_BUILD_TESTS OFF CACHE BOOL "")
set(FXDIV_BUILD_BENCHMARKS OFF CACHE BOOL "")
add_subdirectory(
29 changes: 29 additions & 0 deletions ports/libtorch/fix-sources.patch
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,32 @@ index 9e8a995..2c54558 100644
#include <chrono>
#include <cmath>
#include <fstream>
diff --git a/c10/util/Logging.cpp b/c10/util/Logging.cpp
index b328d25..ab58966 100644
--- a/c10/util/Logging.cpp
+++ b/c10/util/Logging.cpp
@@ -257,23 +257,13 @@ C10_DEFINE_int(
google::GLOG_WARNING,
"The minimum log level that caffe2 will output.");

-// Google glog's api does not have an external function that allows one to check
-// if glog is initialized or not. It does have an internal function - so we are
-// declaring it here. This is a hack but has been used by a bunch of others too
-// (e.g. Torch).
-namespace google {
-namespace glog_internal_namespace_ {
-bool IsGoogleLoggingInitialized();
-} // namespace glog_internal_namespace_
-} // namespace google
-
namespace c10 {
namespace {

void initGoogleLogging(char const* name) {
#if !defined(_MSC_VER)
// This trick can only be used on UNIX platforms
- if (!::google::glog_internal_namespace_::IsGoogleLoggingInitialized())
+ if (!::google::IsGoogleLoggingInitialized())
#endif
{
::google::InitGoogleLogging(name);
1 change: 1 addition & 0 deletions ports/libtorch/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ find_path(SITE_PACKAGES_DIR
PATHS "${PYTHON_ROOT}/Lib/site-packages"
"${PYTHON_ROOT}/lib/python3.11/site-packages"
"${PYTHON_ROOT}/lib/python3.12/site-packages"
"${PYTHON_ROOT}/lib/python3.13/site-packages"
REQUIRED
)
get_filename_component(pybind11_DIR "${SITE_PACKAGES_DIR}/pybind11/share/cmake/pybind11" ABSOLUTE)
Expand Down
11 changes: 0 additions & 11 deletions ports/libtorch/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,8 @@
"glog",
"lapack",
"libkineto",
"libkineto",
"lmdb",
"mimalloc",
{
"name": "mimalloc",
"platform": "windows"
},
"onnx",
"onnx-optimizer",
"opencl",
Expand All @@ -57,12 +52,6 @@
},
"xnnpack"
],
"default-features": [
{
"name": "cuda",
"platform": "windows & x64"
}
],
"features": {
"cuda": {
"description": "Build with CUDA GPU backend",
Expand Down

0 comments on commit e2a8a8f

Please sign in to comment.