From 496ee0c0067275e6b7a0226256b0a8ac27b3ca9c Mon Sep 17 00:00:00 2001 From: Cayetano Santos Date: Fri, 5 Sep 2025 10:19:16 +0200 Subject: [PATCH] gnu: Add onednn. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/packages/oneapi.scm (onednn): New variable. Change-Id: I10e5446aefea2978134495d25b9df504114a7530 Signed-off-by: Ludovic Courtès --- gnu/packages/oneapi.scm | 77 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/gnu/packages/oneapi.scm b/gnu/packages/oneapi.scm index a90eaf06324f980e9905e20b3e800e87c64bc0b7..d17f918a20726fc52fcbbc5f42128878607e680b 100644 --- a/gnu/packages/oneapi.scm +++ b/gnu/packages/oneapi.scm @@ -18,6 +18,9 @@ (define-module (gnu packages oneapi) #:use-module (gnu packages) + #:use-module (gnu packages check) + #:use-module (gnu packages cpp) + #:use-module (gnu packages llvm) #:use-module (gnu packages python) #:use-module (gnu packages swig) #:use-module (guix build-system cmake) @@ -27,6 +30,80 @@ #:use-module (guix packages) #:use-module (guix utils)) +;;; Updates and replaces oneapi-dnnl in (gnu packages machine-learning) +(define-public onednn + ;; See doc/build/build.md. + (package + (name "onednn") + (version "3.9.2") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/uxlfoundation/oneDNN/") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 "0ybq8zb4dcd2g139gdq4bpv20v9jgws5d7ln3x4s0ydrmbgm2qwj")) + (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 + (list + #:configure-flags ;see doc/build/build_options.md + #~(list + #$@(if (target-riscv64?) + (list "-DDNNL_CPU_RUNTIME=SEQ") + ;; Default; also tbb and sycl. + (list "-DDNNL_CPU_RUNTIME=OMP")) + "-DDNNL_EXPERIMENTAL_UKERNEL=ON" ;Used in PyTorch + "-DONEDNN_BUILD_GRAPH=OFF") ;See scripts/README.md + #:phases + #~(modify-phases %standard-phases + ;; This test times out after 3600 seconds. + (add-after 'unpack 'disable-matmul-testing + (lambda _ + (substitute* "tests/benchdnn/benchdnn.cpp" + (("matmul::bench.*") ";\n")))) + ;; See scripts/README.md. + (add-after 'configure 'codegen + (lambda _ + (with-directory-excursion "../source" + ;; Generate types.xml. + (invoke "castxml" "--castxml-cc-gnu-c" "clang" + "--castxml-output=1" "-Iinclude" "-I../build/include" + "include/oneapi/dnnl/dnnl_types.h" "-o" "types.xml") + ;; Run generate_dnnl_debug.py. + (invoke + "python3" "scripts/generate_dnnl_debug.py" "types.xml") + ;; Generating format tags. + ;; Modifies include/oneapi/dnnl/dnnl.hpp + (invoke "python3" "scripts/generate_format_tags.py"))))))) + (native-inputs + (list castxml clang-17 googletest python-minimal-wrapper)) + (home-page "https://uxlfoundation.github.io/oneDNN/") + (synopsis "Deep neural network library") + (description + "@acronym{OneDNN, OneAPI Deep Neural Network Library} is a cross-platform +performance library of basic building blocks for deep learning applications.") + (supported-systems %64bit-supported-systems) + (license license:asl2.0))) + ;;; Updates and replaces tbb in (gnu packages tbb) (define-public onetbb (package