Subject: [bug#75708] [PATCH v2 12/14] gnu: python-pytorch-for-r-torch: Fix build.

From: David Elsing <[email-masked]>
Date: Wed, 22 Jan 2025 18:32:23 +0000

The build fails because the types of function pointers with return type
'__m256' and 'const __m256' (or '__m512' and 'const __m512') are not treated
as compatible by the compiler.

* gnu/packages/machine-learning.scm (python-pytorch-for-r-torch)
[arguments]: New field.
[inputs]: Add foxi.
---
 gnu/packages/machine-learning.scm | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 2fcaea834f..e21736ab67 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -5129,11 +5129,23 @@ (define-public python-pytorch-for-r-torch
     (name "python-pytorch")
     (version %python-pytorch-for-r-torch-version)
     (source %python-pytorch-for-r-torch-src)
+    (arguments
+     (substitute-keyword-arguments (package-arguments python-pytorch)
+       ((#:phases phases)
+        #~(modify-phases #$phases
+            ;; See https://github.com/pytorch/pytorch/issues/61244
+            (add-after 'unpack 'fix-aten-vec
+              (lambda _
+                (substitute*
+                    '("aten/src/ATen/cpu/vec/vec512/vec512_bfloat16.h"
+                      "aten/src/ATen/cpu/vec/vec256/vec256_bfloat16.h")
+                  (("map\\(const __") "map(__"))))))))
     (native-inputs
      (modify-inputs (package-native-inputs python-pytorch)
        (replace "ideep-pytorch" ideep-pytorch-for-r-torch)))
     (inputs
      (modify-inputs (package-inputs python-pytorch)
+       (prepend foxi)
        (prepend qnnpack)
        (replace "qnnpack-pytorch" qnnpack-pytorch-for-r-torch)
        (replace "oneapi-dnnl" oneapi-dnnl-for-r-torch)
-- 
2.46.0