summaryrefslogtreecommitdiff
path: root/gnu/packages/machine-learning.scm
diff options
context:
space:
mode:
authorDavid Elsing <david.elsing@posteo.net>2024-03-23 22:05:02 +0000
committerLudovic Courtès <ludo@gnu.org>2024-06-18 11:44:31 +0200
commit048e5a069279b619fad335f3f0ff69dfacfe2612 (patch)
tree6eb105747751476622ece1f7531677ae9ab7c240 /gnu/packages/machine-learning.scm
parentb032109b5c522505bbadbec82499e9dadfdbc9e6 (diff)
downloadguix-patches-048e5a069279b619fad335f3f0ff69dfacfe2612.tar
guix-patches-048e5a069279b619fad335f3f0ff69dfacfe2612.tar.gz
gnu: xnnpack: Update to commit 51a9875.
The tests which fail to build if building the shared library are removed by a patch. Autogenerated files are removed by a snippet and generated in a separate build phase. * gnu/packages/machine-learning.scm (xnnpack): Update to commit 51a9875. [source]: Add patch for tests. Add snippet to remove autogenerated files. [arguments]: New modules and phase arguments. [inputs]: Add clog and cpuinfo. [native-inputs]: New field. * gnu/packages/patches/xnnpack-remove-broken-tests.patch: Add file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/patches/xnnpack-system-libraries.patch: Update patch.
Diffstat (limited to 'gnu/packages/machine-learning.scm')
-rw-r--r--gnu/packages/machine-learning.scm110
1 files changed, 91 insertions, 19 deletions
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 6c17481131..067935061e 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -4094,41 +4094,110 @@ on quantized 8-bit tensors.")
(define-public xnnpack
;; There's currently no tag on this repo.
(let ((version "0.0")
- (commit "ae108ef49aa5623b896fc93d4298c49d1750d9ba")
- (revision "2"))
+ (commit "51a987591a6fc9f0fc0707077f53d763ac132cbf")
+ (revision "3"))
(package
(name "xnnpack")
(version (git-version version revision commit))
(home-page "https://github.com/google/XNNPACK") ;fork of QNNPACK
- (source (origin
- (method git-fetch)
- (uri (git-reference (url home-page) (commit commit)))
- (file-name (git-file-name name version))
- (sha256
- (base32
- "0q68q2jxiiiblx45q4337k13ppgh5vqjwrwznchcnpb8hawjj3zl"))
- (patches (search-patches "xnnpack-system-libraries.patch"))))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference (url home-page) (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1rzby82xq8d0rl1d148yz88jh9cpsw5c8b2yw7yg39mi7qmr55rm"))
+ ;; Some tests fail to link as they use internal symbols, which are
+ ;; not included in the shared library.
+ ;; XXX: Additionally, these tests fail on i686 due to incorrect results:
+ ;; 171 - f32-vlrelu-test (Failed)
+ ;; 211 - qs8-gavgpool-minmax-fp32-test (Failed)
+ ;; 224 - qu8-avgpool-minmax-fp32-test (Failed)
+ ;; 228 - qu8-gavgpool-minmax-fp32-test (Failed)
+ ;; 263 - x32-packx-test (Failed)
+ (patches (search-patches "xnnpack-remove-broken-tests.patch"))
+ (modules '((guix build utils)
+ (ice-9 ftw)
+ (ice-9 textual-ports)
+ (srfi srfi-26)))
+ (snippet
+ '(begin
+ ;; Remove autogenerated files
+ (for-each
+ (lambda (dir)
+ (let ((gendir (string-append "src/" dir "/gen")))
+ (when (file-exists? gendir)
+ (delete-file-recursively gendir)
+ ;; Needed for the scripts generating the files
+ (mkdir gendir))))
+ (scandir "src" (negate (cut member <> '("." "..")))))
+ (delete-file-recursively "google3")
+ (delete-file "cmake/microkernels.cmake")
+ ;; Additional autogenerated files which contain the string
+ ;; "Auto-generated file"
+ (for-each
+ (lambda (dir)
+ (for-each
+ (lambda (name)
+ (let ((path (string-append dir "/" name)))
+ (when (call-with-input-file path
+ (lambda (port)
+ (string-contains
+ (get-string-all port)
+ "Auto-generated file")))
+ (delete-file path))))
+ (scandir dir (negate (cut member <> '("." ".."))))))
+ '("test" "bench" "eval" "models" "src/enums" "src/xnnpack"))))))
(build-system cmake-build-system)
(arguments
- '(#:configure-flags '("-DXNNPACK_USE_SYSTEM_LIBS=YES"
+ (list
+ #:build-type "Release" ;; Debugging symbols require a lot of disk space
+ #:configure-flags ''("-DXNNPACK_USE_SYSTEM_LIBS=YES"
"-DBUILD_SHARED_LIBS=ON"
+ "-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
"-DXNNPACK_LIBRARY_TYPE=shared"
- "-DXNNPACK_BUILD_TESTS=FALSE" ;FIXME: see below
"-DXNNPACK_BUILD_BENCHMARKS=FALSE")
-
- ;; FIXME: Building tests leads to a CMake error:
- ;;
- ;; ADD_LIBRARY cannot create target "all_microkernels" because
- ;; another target with the same name already exists.
- #:tests? #f))
+ #:modules '((ice-9 ftw)
+ (guix build cmake-build-system)
+ (guix build utils))
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'fix-cmake
+ (lambda _
+ (substitute* "CMakeLists.txt"
+ (("TARGET_INCLUDE_DIRECTORIES\\((pthreadpool|cpuinfo).*") "")
+ ((".*IF\\(NOT TARGET gtest\\).*")
+ "IF(FALSE)\n")
+ (("SET\\(CMAKE_CXX_STANDARD 11\\)")
+ "SET(CMAKE_CXX_STANDARD 14)")
+ (("AMD64") "x86_64"))))
+ (add-after 'patch-source-shebangs 'generate-files
+ (lambda _
+ (for-each
+ (lambda (name)
+ (when (and (string-prefix? "generate" name)
+ (string-suffix? ".sh" name)
+ (not (equal? "generate-amalgamation.sh" name)))
+ (display (string-append name "\n"))
+ (invoke "bash" (string-append "scripts/" name))))
+ (scandir "scripts"))
+ ;; These need to run after the above scripts
+ (display "Remaining files\n")
+ (invoke "python3" "tools/update-microkernels.py")
+ (substitute* "tools/amalgamate-microkernels.py"
+ (("BUILD") "BUILD.bazel"))
+ (invoke "bash" "scripts/generate-amalgamation.sh"))))))
(inputs
- (list cpuinfo
+ (list clog
+ cpuinfo
pthreadpool
googletest
googlebenchmark
fxdiv
fp16
psimd))
+ (native-inputs (list python-pyyaml python-wrapper))
(synopsis "Optimized floating-point neural network inference operators")
(description
"XNNPACK is a highly optimized library of floating-point neural network
@@ -4137,6 +4206,9 @@ intended for direct use by deep learning practitioners and researchers;
instead it provides low-level performance primitives for accelerating
high-level machine learning frameworks, such as TensorFlow Lite,
TensorFlow.js, PyTorch, and MediaPipe.")
+ (supported-systems
+ '("armv7-linux" "aarch64-linux" "riscv64-linux"
+ "i686-linux" "x86_64-linux" "i686-mingw" "x86_64-mingw"))
(license license:bsd-3))))
(define-public xnnpack-for-torch2