summaryrefslogtreecommitdiff
path: root/gnu/packages
diff options
context:
space:
mode:
authorAndy Tai <[email protected]>2025-03-05 23:35:41 -0800
committerNicolas Goaziou <[email protected]>2025-03-09 01:20:32 +0100
commit5adfe1b8e92ff332656bcc7a9d71a35306b3411e (patch)
tree5bb2e3ba2a9d7976cc8b5115b6a59750b208ae97 /gnu/packages
parent9b50aa9bfc61addbf0d4760ac9c09d76e56d906b (diff)
gnu: Add tvm.
* gnu/packages/machine-learning.scm (tvm): New variable. * gnu/packages/patches/tvm_fix_cpptest_build.patch: New file. * gnu/local.mk: Register new file. Change-Id: Icfee19fccc7cc1c9f6d5d6bb680b554d777f62d6 Signed-off-by: Nicolas Goaziou <[email protected]>
Diffstat (limited to 'gnu/packages')
-rw-r--r--gnu/packages/machine-learning.scm91
-rw-r--r--gnu/packages/patches/tvm_fix_cpptest_build.patch18
2 files changed, 109 insertions, 0 deletions
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 288e06e959..246b004156 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -93,6 +93,7 @@
#: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 @@
#: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)
@@ -4630,6 +4632,95 @@ rich objects from one process to another while using the fastest transport for
the tensors contained therein.")
(license license:bsd-3))))
+(define-public tvm
+ ;; Include a bug fix post 0.19 release.
+ (let ((commit "d3a2ed68a42f8b51d8ab1533b62e837b9ea74b8e")
+ (revision "1"))
+ (package
+ (name "tvm")
+ (version (git-version "0.20.dev0" revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/apache/tvm")
+ (commit commit)))
+ (patches (search-patches "tvm_fix_cpptest_build.patch"))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0ng52i0aydljnlrkyg069838c8b311fynhy5976w74smma2m7v72"))))
+ (build-system cmake-build-system)
+ (arguments
+ (list
+ #:test-target "cpptest"
+ #:configure-flags
+ #~(list "-DUSE_OPENCL=ON"
+ "-DUSE_VULKAN=ON"
+ "-DUSE_OPENCL_ENABLE_HOST_PTR=ON"
+ "-DINSTALL_DEV=ON"
+ "-DUSE_GTEST=ON"
+ "-DHIDE_PRIVATE_SYMBOLS=ON" ;per upstream build instructions
+ "-DUSE_LLVM=llvm-config\\ --ignore-libllvm\\ --link-static"
+ ;; per upstream build instructions
+ (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
+ (replace 'check
+ (lambda* (#:key source test-target tests? #:allow-other-keys)
+ (when tests?
+ (begin
+ (invoke "make" "-j"
+ (number->string (parallel-job-count)) test-target)
+ ;; Disable below the actual run of the tests because
+ ;; several fail due to platform variations (for example,
+ ;; fp16 tests fail because not supported on CPUs).
+ ;;
+ ;; (chdir "..")
+ ;; (invoke (which "bash")
+ ;; (string-append source
+ ;; "/tests/scripts/task_cpp_unittest.sh"))
+ )))))))
+ (inputs (list dmlc-core-next
+ dlpack
+ libedit
+ libxml2
+ llvm-19
+ opencl-clhpp
+ opencl-headers
+ rang
+ mesa
+ mesa-opencl
+ spirv-headers
+ spirv-tools
+ vulkan-headers ;TODO; now not building due to missing vta-hw
+ vulkan-loader
+ zlib
+ zstd))
+ (native-inputs (list bash-minimal
+ gcc-14
+ googletest
+ (module-ref (resolve-interface '(gnu packages debug))
+ 'libbacktrace)
+ pkg-config
+ python
+ python-cython))
+ (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")
diff --git a/gnu/packages/patches/tvm_fix_cpptest_build.patch b/gnu/packages/patches/tvm_fix_cpptest_build.patch
new file mode 100644
index 0000000000..7c3efac549
--- /dev/null
+++ b/gnu/packages/patches/tvm_fix_cpptest_build.patch
@@ -0,0 +1,18 @@
+Fix build of cpptest by correcting relative include paths
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 757b0d1a8..546ecd516 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -778,6 +778,11 @@ endif()
+ if(GTEST_FOUND)
+ tvm_file_glob(GLOB_RECURSE TEST_SRCS tests/cpp/*.cc)
+ add_executable(cpptest ${TEST_SRCS})
++
++ # fix building cpptest if we don't use 3rdParty subtree as when building with GNU Guix
++ # allowng relative paths starting with ../../.. to point to the top of the source dir
++ target_include_directories(cpptest PRIVATE tests/cpp/runtime)
++
+ # include runtime files for unit testing
+ target_link_libraries(cpptest PRIVATE ${TVM_TEST_LIBRARY_NAME} GTest::GTest GTest::Main GTest::gmock pthread dl)
+ if(DEFINED LLVM_LIBS)