* 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 <mail@nicolasgoaziou.fr>
---
gnu/local.mk | 1 +
gnu/packages/machine-learning.scm | 86 +++++++++++++++++++
.../patches/tvm_fix_cpptest_build.patch | 18 ++++
3 files changed, 105 insertions(+)
create mode 100644 gnu/packages/patches/tvm_fix_cpptest_build.patch
Toggle diff (149 lines)
diff --git a/gnu/local.mk b/gnu/local.mk
index 09b29da79f..c27f8865ad 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2328,6 +2328,7 @@ dist_patch_DATA = \
%D%/packages/patches/turbovnc-custom-paths.patch \
%D%/packages/patches/turbovnc-find-system-packages.patch \
%D%/packages/patches/tuxpaint-stamps-path.patch \
+ %D%/packages/patches/tvm_fix_cpptest_build.patch \
%D%/packages/patches/twinkle-bcg729.patch \
%D%/packages/patches/u-boot-allow-disabling-openssl.patch \
%D%/packages/patches/u-boot-nintendo-nes-serial.patch \
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 7e354ec40a..fcb4386cae 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,90 @@ (define-public tensorpipe
the tensors contained therein.")
(license license:bsd-3))))
+(define-public tvm
+ ;; a bug fix post 0.19 releaqse
+ (let ((commit "d3a2ed68a42f8b51d8ab1533b62e837b9ea74b8e"))
+ (package
+ (name "tvm")
+ (version (string-append "0.20.dev0-1."
+ (string-take commit 8)))
+ (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 (string-append name "-" version "-checkout"))
+ (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 the below actual run of the tests because several fail due to platform variations (for example, fp16 tests fail bewcause 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)
--
2.48.1