Subject: [PATCH 6/6] gnu: Add arrayfire.

From: Adam Faiz <[email-masked]>
Date: Sun, 27 Aug 2023 02:56:34 +0800

>From 0d1c25484158655344cbfbdc1e3e503be23654d1 Mon Sep 17 00:00:00 2001
Message-ID: <0[email-masked]>
In-Reply-To: <[email-masked]>
References: <[email-masked]>
From: AwesomeAdam54321 <[email-masked]>
Date: Sun, 27 Aug 2023 02:12:03 +0800
Subject: [PATCH 6/6] gnu: Add arrayfire.

* gnu/packages/machine-learning.scm (arrayfire): New variable.
---
 gnu/packages/machine-learning.scm | 71 +++++++++++++++++++++++++++++++
 1 file changed, 71 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 6251ea9206..e2ca22821b 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -69,6 +69,8 @@ (define-module (gnu packages machine-learning)
   #:use-module (gnu packages cran)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages dejagnu)
+  #:use-module (gnu packages documentation)
+  #:use-module (gnu packages fontutils)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages gettext)
@@ -85,6 +87,7 @@ (define-module (gnu packages machine-learning)
   #:use-module (gnu packages libffi)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages llvm)
+  #:use-module (gnu packages logging)
   #:use-module (gnu packages maths)
   #:use-module (gnu packages mpi)
   #:use-module (gnu packages ninja)
@@ -93,6 +96,7 @@ (define-module (gnu packages machine-learning)
   #:use-module (gnu packages parallel)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages pretty-print)
   #:use-module (gnu packages protobuf)
   #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages python)
@@ -3102,6 +3106,73 @@ (define-public tensorflow-lite
 devices.")
     (license license:asl2.0)))
 
+(define-public arrayfire
+  (package
+    (name "arrayfire")
+    (version "3.8.3")
+    (source
+      (origin
+        (method git-fetch)
+        (uri (git-reference
+               (url "https://github.com/arrayfire/arrayfire.git")
+               (commit (string-append "v" version))))
+        (sha256
+         (base32 "1fvd0jvg49inhqx0mcqrfsfnqvc3n0pgnym5gina5svgh293n68a"))
+        (modules '((guix build utils)))
+        (snippet
+         #~(begin
+             (substitute* "CMakeLists.txt"
+               (("add_subdirectory\\(\\$.*\\)") "")
+               (("NO_CMAKE_PACKAGE_REGISTRY") "")
+               (("include\\(AFconfigure_deps_vars\\)")
+                (string-append "macro(af_dep_check_and_populate dep_prefix)\n"
+                               "endmacro()"))
+               (("....assets_prefix._SOURCE_DIR.")
+                "$ENV{ARRAYFIRE_DOCS_PREFIX}"))
+             (substitute* "test/CMakeLists.txt"
+               (("include\\(download_sparse_datasets\\)") ""))
+             (substitute* "CMakeModules/FindFFTW.cmake"
+               (("FFTWF_LIBRARY\\)") ")"))
+             (substitute* "src/backend/cpu/CMakeLists.txt"
+               (("....threads_prefix._.*hpp") ""))))
+        (file-name (git-file-name name version))))
+    (build-system cmake-build-system)
+    (native-inputs
+     (list arrayfire-docs
+           doxygen
+           googletest
+           pkg-config))
+    (inputs
+     (list arrayfire-forge
+           arrayfire-glad
+           arrayfire-threads
+           boost
+           fftw
+           fmt
+           fontconfig
+           freeimage
+           glfw
+           lapack
+           libomp
+           openblas
+           span-lite
+           spdlog))
+    (arguments
+     (list #:configure-flags
+           #~(list "-DCMAKE_EXE_LINKER_FLAGS=-Wl,--no-keep-memory")
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-before 'configure 'set-envs
+                 (lambda _
+                   (setenv "ARRAYFIRE_DOCS_PREFIX"
+                           #$(this-package-native-input "arrayfire-docs")))))))
+    (home-page "https://arrayfire.com/")
+    (synopsis "General purpose tensor library")
+    (description "ArrayFire is a general-purpose tensor library that simplifies
+the process of software development for the parallel architectures found in
+CPUs, GPUs, and other hardware acceleration devices.")
+    (license license:bsd-3)))
+
 (define-public arrayfire-docs
   (let ((commit "cd08d749611b324012555ad6f23fd76c5465bd6c")
         (revision "0"))
-- 
2.41.0