git: 705e9e930b1a - main - misc/py-pytorch: Fix run-time failure: error: use of undeclared identifier '__assert_fail'

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Fri, 17 Nov 2023 17:00:33 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=705e9e930b1a2b12ee18d0becc94174a2c0c94f9

commit 705e9e930b1a2b12ee18d0becc94174a2c0c94f9
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2023-11-17 16:58:42 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2023-11-17 17:00:31 +0000

    misc/py-pytorch: Fix run-time failure: error: use of undeclared identifier '__assert_fail'
    
    One particular GPU-related assert macro has to be patched to be a regular assert.
    The problem was reported to the upstream.
---
 misc/py-pytorch/Makefile                           |  1 +
 misc/py-pytorch/files/patch-CMakeLists.txt         | 10 +++++-----
 misc/py-pytorch/files/patch-c10_core_DynamicCast.h | 12 +++++++++++-
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/misc/py-pytorch/Makefile b/misc/py-pytorch/Makefile
index cdf87794c265..6f43ace1e6ca 100644
--- a/misc/py-pytorch/Makefile
+++ b/misc/py-pytorch/Makefile
@@ -1,6 +1,7 @@
 PORTNAME=	pytorch
 DISTVERSIONPREFIX=	v
 DISTVERSION=	2.1.0
+PORTREVISION=	1
 CATEGORIES=	misc # machine-learning
 MASTER_SITES=	https://github.com/pytorch/pytorch/releases/download/v${DISTVERSION}/
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
diff --git a/misc/py-pytorch/files/patch-CMakeLists.txt b/misc/py-pytorch/files/patch-CMakeLists.txt
index 9ebebccbf2e3..4b319d3c9aac 100644
--- a/misc/py-pytorch/files/patch-CMakeLists.txt
+++ b/misc/py-pytorch/files/patch-CMakeLists.txt
@@ -1,6 +1,6 @@
---- CMakeLists.txt.orig	2023-04-03 19:45:59 UTC
+--- CMakeLists.txt.orig	2023-10-06 19:49:00 UTC
 +++ CMakeLists.txt
-@@ -138,7 +138,7 @@ endif()
+@@ -139,7 +139,7 @@ endif()
  set(CPU_AARCH64 OFF)
  set(CPU_INTEL OFF)
  
@@ -9,7 +9,7 @@
    set(CPU_INTEL ON)
  elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)")
    set(CPU_AARCH64 ON)
-@@ -163,7 +163,7 @@ include(CMakeDependentOption)
+@@ -164,7 +164,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)
@@ -18,7 +18,7 @@
  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()
+@@ -408,15 +408,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)
@@ -35,5 +35,5 @@
 -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_SYSTEM_ZSTD "Use system-provided zstd." OFF)
  option(USE_GOLD_LINKER "Use ld.gold to link" OFF)
- if(USE_SYSTEM_LIBS)
diff --git a/misc/py-pytorch/files/patch-c10_core_DynamicCast.h b/misc/py-pytorch/files/patch-c10_core_DynamicCast.h
index 517085e8bdee..096c85f368f8 100644
--- a/misc/py-pytorch/files/patch-c10_core_DynamicCast.h
+++ b/misc/py-pytorch/files/patch-c10_core_DynamicCast.h
@@ -1,8 +1,18 @@
 - 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'
+- see https://github.com/pytorch/pytorch/issues/113941
 
---- c10/core/DynamicCast.h.orig	2023-05-10 02:37:18 UTC
+--- c10/core/DynamicCast.h.orig	2023-10-06 19:49:01 UTC
 +++ c10/core/DynamicCast.h
+@@ -54,7 +54,7 @@ namespace c10 {
+ //
+ 
+ #ifdef C10_HOST_DEVICE
+-#define ERROR_UNSUPPORTED_CAST CUDA_KERNEL_ASSERT(false);
++#define ERROR_UNSUPPORTED_CAST assert(false);
+ #else
+ #define ERROR_UNSUPPORTED_CAST TORCH_CHECK(false, "Unexpected scalar type");
+ #endif
 @@ -99,13 +99,13 @@ C10_HOST_DEVICE inline void cast_and_store(
    template <>                                                 \
    C10_HOST_DEVICE inline T fetch_and_cast<T>(                 \