[bug#63991,v3,3/3] gnu: Add tvm.

Message ID 9a88cefe0bc3ab606570f4b3372af7ec61b5c1d0.1741031015.git.atai@atai.org
State New
Headers
Series *** Add Apache Tvm *** |

Commit Message

Andy Tai March 3, 2025, 7:45 p.m. UTC
  * gnu/packages/machine-learning.scm (tvm): New variable.

Change-Id: Icfee19fccc7cc1c9f6d5d6bb680b554d777f62d6
Signed-off-by: Nicolas Goaziou <mail@nicolasgoaziou.fr>
---
 gnu/packages/machine-learning.scm | 72 +++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
  

Patch

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 7e354ec40a..0a84c3b77a 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -93,6 +93,7 @@  (define-module (gnu packages machine-learning)
   #:use-module (gnu packages image-processing)
   #:use-module (gnu packages imagemagick)
   #:use-module (gnu packages jupyter)
+  #:use-module (gnu packages libedit)
   #:use-module (gnu packages libevent)
   #:use-module (gnu packages libffi)
   #:use-module (gnu packages linux)
@@ -117,6 +118,7 @@  (define-module (gnu packages machine-learning)
   #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages rdf)
   #:use-module (gnu packages regex)
+  #:use-module (gnu packages rocm)
   #:use-module (gnu packages rpc)
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages serialization)
@@ -4629,6 +4631,76 @@  (define-public tensorpipe
 the tensors contained therein.")
       (license license:bsd-3))))
 
+(define-public tvm
+  (package
+    (name "tvm")
+    (version "0.19.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/apache/tvm")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1s8yrd7v38ianm7g2qzk25q6aa23mscwwixpjj0n562z9hgv5nry"))))
+    (build-system cmake-build-system)
+    (arguments
+     (list #:tests? #false      ; tests do not build in this release so do not
+                                ; build or tun them #:test-target "test"
+           #:configure-flags
+           #~(list "--trace"
+                   "-DUSE_OPENCL=ON"
+                   "-DUSE_VULKAN=ON" ;TODO; now not building due to missing vta-hw
+                   "-DUSE_OPENCL_ENABLE_HOST_PTR=ON"
+                   "-DINSTALL_DEV=ON"
+                                        ;"-DUSE_GTEST=ON"  ; TODO: enable tests in future releases
+                   (string-append "-DDLPACK_PATH="
+                                  (assoc-ref %build-inputs "dlpack")
+                                  "/include")
+                   (string-append "-DDMLC_PATH="
+                                  (assoc-ref %build-inputs "dmlc-core")
+                                  "/include")
+                   (string-append "-DRANG_PATH="
+                                  (assoc-ref %build-inputs "rang")
+                                  "/include"))
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'unpack 'enable-cpptest-build
+                 (lambda _
+                   (substitute* "CMakeLists.txt"
+                     (("set_target_properties\\(cpptest PROPERTIES EXCLUDE_FROM_ALL 1\\)")
+                      "")))))))
+    (inputs (list dmlc-core-next
+                  dlpack
+                  libedit
+                  libxml2
+                  opencl-clhpp
+                  opencl-headers
+                  rang
+                  zlib
+                  mesa
+                  mesa-opencl
+                  spirv-headers
+                  spirv-tools
+                  vulkan-headers ;TODO; now not building due to missing vta-hw
+                  vulkan-loader))
+    (native-inputs (list ;googletest  ;commented out to avoid building tests for now as tests do not build
+                         (module-ref (resolve-interface '(gnu packages debug))
+                                     'libbacktrace)
+                         pkg-config
+                         python))
+    (home-page "https://tvm.apache.org/")
+    (synopsis
+     "Machine learning compiler framework for CPUs, GPUs and accelerators")
+    (description
+     "Apache TVM is a compiler stack for deep learning systems.  It is
+designed to close the gap between the productivity-focused deep learning
+frameworks, and the performance- and efficiency-focused hardware backends.
+TVM works with deep learning frameworks to provide end to end compilation to
+different backends")
+    (license license:asl2.0)))
+
 (define-public foxi
   (let
       ((commit "c278588e34e535f0bb8f00df3880d26928038cad")