Subject: [PATCH v2 09/14] gnu: oneapi-dnnl: Regenerate autogenerated files.

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

* gnu/packages/machine-learning.scm (oneapi-dnnl)[source]: Add snippet.
[arguments]<#:configure-flags>: Add "-DDNNL_EXPERIMENTAL_UKERNEL=ON".
[arguments]<#:phases>: Add 'codegen phase.
[native-inputs]: New field to add castxml, clang-17 and python.
---
 gnu/packages/machine-learning.scm | 44 ++++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 0b4d9638f0..cbeef84f06 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -6261,11 +6261,47 @@ (define-public oneapi-dnnl
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "1m2d7qlbfk86rmvmpvx2k3rc2k0l9hf9qpa54jl44670ls9n8i7w"))))
+        (base32 "1m2d7qlbfk86rmvmpvx2k3rc2k0l9hf9qpa54jl44670ls9n8i7w"))
+       (modules '((guix build utils)
+                  (ice-9 rdelim)))
+       ;; Copyright date used by code generation script
+       (snippet
+        '(for-each
+          (lambda (file)
+            (with-atomic-file-replacement
+             file
+             (lambda (in out)
+               (let loop ((line (read-line in 'concat)))
+                 (if (string-contains line "Copyright")
+                     (display line out)
+                     (loop (read-line in 'concat)))))))
+          '("include/oneapi/dnnl/dnnl_debug.h"
+            "src/common/dnnl_debug_autogenerated.cpp"
+            "tests/benchdnn/dnnl_debug_autogenerated.cpp"
+            "tests/benchdnn/dnnl_debug.hpp")))))
     (build-system cmake-build-system)
-    (arguments (if (target-riscv64?)
-                   (list #:configure-flags #~'("-DDNNL_CPU_RUNTIME=SEQ"))
-                   '()))
+    (arguments
+     (list
+      #:configure-flags
+      `(list
+        ,@(if (target-riscv64?)
+              (list #:configure-flags '("-DDNNL_CPU_RUNTIME=SEQ"))
+              '())
+        ;; Used in PyTorch
+        "-DDNNL_EXPERIMENTAL_UKERNEL=ON")
+      #:phases
+      '(modify-phases %standard-phases
+         (add-after 'configure 'codegen
+           (lambda _
+             (with-directory-excursion "../source"
+               (invoke "castxml" "--castxml-cc-gnu-c" "clang"
+                       "--castxml-output=1" "-DDNNL_EXPERIMENTAL_SPARSE"
+                       "-Iinclude" "-I../build/include"
+                       "include/oneapi/dnnl/dnnl_types.h" "-o" "types.xml")
+               (invoke "python3" "scripts/generate_dnnl_debug.py" "types.xml")
+               ;; Modifies include/oneapi/dnnl/dnnl.hpp
+               (invoke "python3" "scripts/generate_format_tags.py")))))))
+    (native-inputs (list castxml clang-17 python))
     (home-page "https://github.com/oneapi-src/oneDNN")
     (synopsis "Deep Neural Network Library")
     (description
-- 
2.46.0