git: 96da84adbff5 - main - misc/pytorch: Update to 2.1.0

From: Po-Chuan Hsieh <sunpoet_at_FreeBSD.org>
Date: Mon, 27 Nov 2023 10:46:01 UTC
The branch main has been updated by sunpoet:

URL: https://cgit.FreeBSD.org/ports/commit/?id=96da84adbff54be3917b922df418b037d2fc0cc6

commit 96da84adbff54be3917b922df418b037d2fc0cc6
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2023-11-27 10:45:51 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2023-11-27 10:45:51 +0000

    misc/pytorch: Update to 2.1.0
    
    - Add LICENSE_FILE
    - Remove PYTHON_EXECUTABLE which is set by USES=python now
    - Comment BROKEN_* temporarily to see if the new version builds
    
    Changes:        https://github.com/pytorch/pytorch/releases
    PR:             274859
    Approved by:    maintainer (timeout, 25 days)
---
 misc/pytorch/files/patch-CMakeLists.txt            | 39 ++++++++++++++++++++++
 ...aten_src_ATen_cpu_vec_vec256_vec256__bfloat16.h | 11 ++++++
 ...aten_src_ATen_cpu_vec_vec512_vec512__bfloat16.h | 11 ++++++
 misc/pytorch/files/patch-c10_core_DynamicCast.h    | 21 ++++++++++++
 misc/pytorch/files/patch-caffe2_CMakeLists.txt     | 11 ++++++
 .../files/patch-caffe2_proto_CMakeLists.txt        |  8 +++++
 6 files changed, 101 insertions(+)

diff --git a/misc/pytorch/files/patch-CMakeLists.txt b/misc/pytorch/files/patch-CMakeLists.txt
new file mode 100644
index 000000000000..9ebebccbf2e3
--- /dev/null
+++ b/misc/pytorch/files/patch-CMakeLists.txt
@@ -0,0 +1,39 @@
+--- CMakeLists.txt.orig	2023-04-03 19:45:59 UTC
++++ CMakeLists.txt
+@@ -138,7 +138,7 @@ endif()
+ set(CPU_AARCH64 OFF)
+ set(CPU_INTEL OFF)
+ 
+-if(CMAKE_SYSTEM_PROCESSOR MATCHES "(AMD64|x86_64)")
++if(CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64|x86_64)")
+   set(CPU_INTEL ON)
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)")
+   set(CPU_AARCH64 ON)
+@@ -163,7 +163,7 @@ include(CMakeDependentOption)
+ option(ATEN_NO_TEST "Do not build ATen test binaries" OFF)
+ option(BUILD_BINARY "Build C++ binaries" OFF)
+ option(BUILD_DOCS "Build Caffe2 documentation" OFF)
+-option(BUILD_CUSTOM_PROTOBUF "Build and use Caffe2's own protobuf under third_party" ON)
++option(BUILD_CUSTOM_PROTOBUF "Build and use Caffe2's own protobuf under third_party" OFF)
+ option(BUILD_PYTHON "Build Python binaries" ON)
+ option(BUILD_CAFFE2 "Master flag to build Caffe2" OFF)
+ option(BUILD_LITE_INTERPRETER "Master flag to build Lite Interpreter" OFF)
+@@ -398,15 +398,15 @@ endif()
+ # USE_SYSTEM_LIBS being "OFF".
+ option(USE_SYSTEM_LIBS "Use all available system-provided libraries." OFF)
+ option(USE_SYSTEM_CPUINFO "Use system-provided cpuinfo." OFF)
+-option(USE_SYSTEM_SLEEF "Use system-provided sleef." OFF)
++option(USE_SYSTEM_SLEEF "Use system-provided sleef." ON)
+ option(USE_SYSTEM_GLOO "Use system-provided gloo." OFF)
+ option(USE_SYSTEM_FP16 "Use system-provided fp16." OFF)
+-option(USE_SYSTEM_PYBIND11 "Use system-provided PyBind11." OFF)
++option(USE_SYSTEM_PYBIND11 "Use system-provided PyBind11." ON)
+ option(USE_SYSTEM_PTHREADPOOL "Use system-provided pthreadpool." OFF)
+ option(USE_SYSTEM_PSIMD "Use system-provided psimd." OFF)
+ option(USE_SYSTEM_FXDIV "Use system-provided fxdiv." OFF)
+ option(USE_SYSTEM_BENCHMARK "Use system-provided google benchmark." OFF)
+-option(USE_SYSTEM_ONNX "Use system-provided onnx." OFF)
++option(USE_SYSTEM_ONNX "Use system-provided onnx." ON)
+ option(USE_SYSTEM_XNNPACK "Use system-provided xnnpack." OFF)
+ option(USE_GOLD_LINKER "Use ld.gold to link" OFF)
+ if(USE_SYSTEM_LIBS)
diff --git a/misc/pytorch/files/patch-aten_src_ATen_cpu_vec_vec256_vec256__bfloat16.h b/misc/pytorch/files/patch-aten_src_ATen_cpu_vec_vec256_vec256__bfloat16.h
new file mode 100644
index 000000000000..5923cd93c2cd
--- /dev/null
+++ b/misc/pytorch/files/patch-aten_src_ATen_cpu_vec_vec256_vec256__bfloat16.h
@@ -0,0 +1,11 @@
+--- aten/src/ATen/cpu/vec/vec256/vec256_bfloat16.h.orig	2023-10-12 12:49:42 UTC
++++ aten/src/ATen/cpu/vec/vec256/vec256_bfloat16.h
+@@ -266,7 +266,7 @@ static_assert( (public)
+     }
+     return b;
+   }
+-  Vectorized<T> map(const __m256 (*const vop)(__m256)) const {
++  Vectorized<T> map(__m256 (*const vop)(__m256)) const {
+     __m256 lo, hi;
+     cvt_to_fp32<T>(values, lo, hi);
+     const auto o1 = vop(lo);
diff --git a/misc/pytorch/files/patch-aten_src_ATen_cpu_vec_vec512_vec512__bfloat16.h b/misc/pytorch/files/patch-aten_src_ATen_cpu_vec_vec512_vec512__bfloat16.h
new file mode 100644
index 000000000000..80e0b1832434
--- /dev/null
+++ b/misc/pytorch/files/patch-aten_src_ATen_cpu_vec_vec512_vec512__bfloat16.h
@@ -0,0 +1,11 @@
+--- aten/src/ATen/cpu/vec/vec512/vec512_bfloat16.h.orig	2023-10-12 12:54:40 UTC
++++ aten/src/ATen/cpu/vec/vec512/vec512_bfloat16.h
+@@ -345,7 +345,7 @@ static_assert( (public)
+   }
+   #pragma clang diagnostic push
+   #pragma clang diagnostic ignored "-Wignored-qualifiers"
+-  Vectorized<T> map(const __m512 (*const vop)(__m512)) const {
++  Vectorized<T> map(__m512 (*const vop)(__m512)) const {
+     __m512 lo, hi;
+     cvt_to_fp32<T>(values, lo, hi);
+     const auto o1 = vop(lo);
diff --git a/misc/pytorch/files/patch-c10_core_DynamicCast.h b/misc/pytorch/files/patch-c10_core_DynamicCast.h
new file mode 100644
index 000000000000..517085e8bdee
--- /dev/null
+++ b/misc/pytorch/files/patch-c10_core_DynamicCast.h
@@ -0,0 +1,21 @@
+- workaround for the failuree diring math/dgl build:
+- /usr/local/lib/python3.9/site-packages/torch/include/c10/core/DynamicCast.h:112:22: error: use of undeclared identifier '__assert_fail'
+
+--- c10/core/DynamicCast.h.orig	2023-05-10 02:37:18 UTC
++++ c10/core/DynamicCast.h
+@@ -99,13 +99,13 @@ C10_HOST_DEVICE inline void cast_and_store(
+   template <>                                                 \
+   C10_HOST_DEVICE inline T fetch_and_cast<T>(                 \
+       const ScalarType src_type, const void* ptr) {           \
+-    CUDA_KERNEL_ASSERT(ScalarType::scalartype_ == src_type);  \
++    assert(ScalarType::scalartype_ == src_type);  \
+     return c10::load<T>(ptr);                                 \
+   }                                                           \
+   template <>                                                 \
+   C10_HOST_DEVICE inline void cast_and_store<T>(              \
+       const ScalarType dest_type, void* ptr, T value) {       \
+-    CUDA_KERNEL_ASSERT(ScalarType::scalartype_ == dest_type); \
++    assert(ScalarType::scalartype_ == dest_type); \
+     *(T*)ptr = value;                                         \
+   }
+ 
diff --git a/misc/pytorch/files/patch-caffe2_CMakeLists.txt b/misc/pytorch/files/patch-caffe2_CMakeLists.txt
new file mode 100644
index 000000000000..ca8e239a6d85
--- /dev/null
+++ b/misc/pytorch/files/patch-caffe2_CMakeLists.txt
@@ -0,0 +1,11 @@
+--- caffe2/CMakeLists.txt.orig	2023-05-08 19:58:16 UTC
++++ caffe2/CMakeLists.txt
+@@ -1,6 +1,8 @@
+ # ---[ Generate and install header and cpp files
+ include(../cmake/Codegen.cmake)
+ 
++set(CMAKE_CXX_STANDARD 17)
++
+ # ---[ Vulkan code gen
+ if(USE_VULKAN)
+   include(../cmake/VulkanCodegen.cmake)
diff --git a/misc/pytorch/files/patch-caffe2_proto_CMakeLists.txt b/misc/pytorch/files/patch-caffe2_proto_CMakeLists.txt
new file mode 100644
index 000000000000..1df1849c0556
--- /dev/null
+++ b/misc/pytorch/files/patch-caffe2_proto_CMakeLists.txt
@@ -0,0 +1,8 @@
+--- caffe2/proto/CMakeLists.txt.orig	2023-05-08 19:58:16 UTC
++++ caffe2/proto/CMakeLists.txt
+@@ -1,3 +1,5 @@
++set(CMAKE_CXX_STANDARD 17)
++
+ if(BUILD_CAFFE2)
+   file(GLOB Caffe2_PROTOBUF_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.proto")
+ else()