vcpkg/ports/libtorch/fix-windows.patch

101 lines
3.7 KiB
Diff
Raw Normal View History

[libtorch] create a new port (#17199) * [onnx] feature: foxi * https://github.com/houseroad/foxi * install the project's copyright (MIT) * pytorch requires `foxi_loader` The CMake target will be renamed to `onnxifi_*` for convenience. * [onnx] force onnx/onnx_proto static in Windows Checked the protject's CI logs. It turned out onnx/onnx_proto are ALWAYS static. Specify it in CMakeLists.txt because vcpkg configures `BUILD_SHARED_LIBS=ON` If the triplet requires it. There are no `ONNXIFI_ENABLE_EXT=ON` case. Removed the misused build options in portfile. Add port feature `protobuf-lite` which is in build option. * [onnx] support windows static triplets * remove SHARED for `onnxifi_wrapper` and `onnxifi_dummy` * [onnx] fix wrong LICENSE install * [onnx] remove feature 'foxi' * also remove redundant part in patch files * [libtorch] rework patch files * [libtorch] config fixup ATen, Torch * use `link_libraries` to vcpkg installed folder * future work may use library names without `find_library` * update versions JSON to use `version-semver` * [libtorch] make shared only * Caffe2 is exported when BUILD_SHARED_LIBS * [libtorch] remove headers after install * [libtorch] rewrite patches and feature options * checked osx / linux build * [libtorch] use eigen3 always * Caffe2 eigen_utils.h requires it * [libtorch] error if BLAS feature collision * [libtorch] remove !static * [libtorch] replace vcpkg_find_acquire_program * let's see python3 from find_program supports * Dependency python3 * [libtorch] migrate works from luncliff/vcpkg-registry * Update target version and dependencies * Removed unsupported features * [libtorch] misc fix, update version, baseline * fix merge confict for 'onnx' * [libtorch] install pip packages * typing-extensions, pyyaml * [libtorch] turn off Metal options * [onnx] revert 'onnx' changes * [libtorch] refine patches * [libtorch] link with foxi_loader * removed wrong onnx related source changes * [libtorch] update git-tree * [libtorch] reduce patch size * [libtorch] find numa and activate USE_NUMA * Update ports/libtorch/portfile.cmake Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com> * Update ports/libtorch/portfile.cmake Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com> * Update ports/libtorch/portfile.cmake Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com> * [libtorch] fix mistype and update version JSON * Add double quotes * version * Fix support expression * version * [libtorch] update cpuinfo usage * https://github.com/microsoft/vcpkg/pull/23944 * update version * [tensorpipe] fix linux install * find_package(Tensorpipe) may fail because of case mismatch * [tensorpipe] update versions JSON * [libtorch] fix feature failures * [libtorch] remove CUDA feature * [libtorch] giveup 'fbgemm' feature * [libtorch] use mpi, openmpi in Linux * [libtorch] fix glog link error * [tensorpipe] bump port version * see https://github.com/microsoft/vcpkg/pull/23569 * [libtorch] fix patch list * [libtorch] use official libuv config * see https://github.com/microsoft/vcpkg/pull/24745 * Update ports/libtorch/portfile.cmake Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com> * Update ports/libtorch/portfile.cmake Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com> * update versions JSON * revert unnecessary 'nnpack' changes * Update ports/libtorch/portfile.cmake Co-authored-by: Adam Johnson <AdamJohnso@gmail.com> * [libtorch] use vcpkg-get-python-packages * [libtorch] provide path of python3 * Update ports/libtorch/portfile.cmake Co-authored-by: Billy O'Neal <bion@microsoft.com> * Fix version database. * [libtorch] use openmpi in linux/osx * [libtorch] update to v1.12.1 * [libtorch] find_program(python3, python) * [libtorch] provide PYTHON_EXECUTABLE directly * [xnnpack] update to 2022-02-17 * [xnnpack] use C11, C++11 * [libtorch] more patches, DISABLE_PARALLEL_CONFIGURE * [libtorch] allow static torch_cpu build * Revert "[libtorch] allow static torch_cpu build" This reverts commit 5fd4ef0bbe4f56d5c027494c7c571a4f13b37b25. * [libtorch] find_package(BLAS) * [libtorch] simplify Python3, NumPy option use * [libtorch] fix install in Windows * [libtorch] exclude torch_global_deps in Windows * [libtorch] platform of nnpack feature * [libtorch] fix MPI option in Windows * [libtorch] fixing LNK1161 * [libtorch] fix some mistypes * [libtorch] define NOMINMAX for c10 * [libtorch] disable vulkan feature in Windows * ci.baseline.txt: allow libtorch failure * fails with Visual Studio 2022 17.4.2 * requires 17.4.3+ * Enable testing port on Windows * [caffe2] redirect to libtorch * update baseline Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com> Co-authored-by: nicole mazzuca <83086508+strega-nil-ms@users.noreply.github.com> Co-authored-by: Billy Robert O'Neal <bion@microsoft.com> Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com> Co-authored-by: Adam Johnson <AdamJohnso@gmail.com> Co-authored-by: Victor Romero <romerosanchezv@gmail.com>
2023-01-19 03:06:34 +08:00
diff --git a/torch/csrc/jit/tensorexpr/bounds_overlap.h b/torch/csrc/jit/tensorexpr/bounds_overlap.h
index c78884d..baf44bb 100644
--- a/torch/csrc/jit/tensorexpr/bounds_overlap.h
+++ b/torch/csrc/jit/tensorexpr/bounds_overlap.h
@@ -65,6 +65,10 @@ enum OverlapKind { ContainedOrEqual, Contains, PartialOverlap, NoOverlap };
// operator
// NOT_DETERMINED: Some elements satify the given comparison operator and
// some elements not
+#if defined(_WIN32)
+#undef TRUE
+#undef FALSE
+#endif
enum CmpEvalResult { TRUE, FALSE, NOT_DETERMINED };
// Returns the kind of overlap between Bound A and Bound A in a single
diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt
index 3390f9b..578d0bd 100644
--- a/caffe2/CMakeLists.txt
+++ b/caffe2/CMakeLists.txt
@@ -1425,7 +1425,7 @@ target_include_directories(torch_cpu SYSTEM PRIVATE "${Caffe2_DEPENDENCY_INCLUDE
torch_set_target_props(torch_cpu)
-target_compile_options(torch_cpu PRIVATE "-DCAFFE2_BUILD_MAIN_LIB")
+target_compile_definitions(torch_cpu PRIVATE CAFFE2_BUILD_MAIN_LIB)
if(BUILD_SPLIT_CUDA)
target_compile_options(torch_cuda_cu PRIVATE "-DTORCH_CUDA_CU_BUILD_MAIN_LIB")
target_compile_options(torch_cuda_cpp PRIVATE "-DTORCH_CUDA_CPP_BUILD_MAIN_LIB")
@@ -1525,12 +1525,12 @@ if(MSVC AND NOT BUILD_SHARED_LIBS)
#
# NB: This must be target_compile_definitions, not target_compile_options,
# as the latter is not respected by nvcc
- target_compile_definitions(torch_cpu PUBLIC "AT_CORE_STATIC_WINDOWS=1")
+ target_compile_definitions(torch_cpu PUBLIC AT_CORE_STATIC_WINDOWS=1)
endif()
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")
+ target_compile_definitions(torch_cpu PRIVATE ONNX_BUILD_MAIN_LIB)
endif()
caffe2_interface_library(torch_cpu torch_cpu_library)
diff --git a/aten/src/ATen/Parallel.h b/aten/src/ATen/Parallel.h
index 0b494d9..06b5d88 100644
--- a/aten/src/ATen/Parallel.h
+++ b/aten/src/ATen/Parallel.h
@@ -28,13 +28,7 @@ TORCH_API bool in_parallel_region();
namespace internal {
// Initialise num_threads lazily at first parallel call
-inline TORCH_API void lazy_init_num_threads() {
- thread_local bool init = false;
- if (C10_UNLIKELY(!init)) {
- at::init_num_threads();
- init = true;
- }
-}
+TORCH_API void lazy_init_num_threads();
TORCH_API void set_thread_num(int);
diff --git a/aten/src/ATen/ParallelCommon.cpp b/aten/src/ATen/ParallelCommon.cpp
index 068c9d3..b869fde 100644
--- a/aten/src/ATen/ParallelCommon.cpp
+++ b/aten/src/ATen/ParallelCommon.cpp
@@ -17,6 +17,17 @@
namespace at {
+namespace internal {
+/// @see https://github.com/pytorch/pytorch/issues/87957
+void lazy_init_num_threads() {
+ thread_local bool init = false;
+ if (C10_UNLIKELY(!init)) {
+ at::init_num_threads();
+ init = true;
+ }
+}
+} // namespace internal
+
namespace {
const char* get_env_var(
diff --git a/c10/CMakeLists.txt b/c10/CMakeLists.txt
index 3b390ec..7cfa2b0 100644
--- a/c10/CMakeLists.txt
+++ b/c10/CMakeLists.txt
@@ -45,7 +45,10 @@ if(HAVE_SOVERSION)
VERSION ${TORCH_VERSION} SOVERSION ${TORCH_SOVERSION})
endif()
# If building shared library, set dllimport/dllexport proper.
-target_compile_options(c10 PRIVATE "-DC10_BUILD_MAIN_LIB")
+target_compile_definitions(c10 PRIVATE C10_BUILD_MAIN_LIB)
+if(WIN32)
+ target_compile_definitions(c10 PRIVATE NOMINMAX)
+endif()
# Enable hidden visibility if compiler supports it.
if(${COMPILER_SUPPORTS_HIDDEN_VISIBILITY})
target_compile_options(c10 PRIVATE "-fvisibility=hidden")