summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Graves <ngraves@ngraves.fr>2025-08-30 03:24:20 +0200
committerAndreas Enge <andreas@enge.fr>2025-09-20 13:13:33 +0200
commit8f57e6c9960a490072276b197e04d8858ff1ea68 (patch)
treea1f0db02f9aff736ae687914b2ee6e38370705e1
parent14e0bca6ddb2f30e943962d6bee50a6da5df4c67 (diff)
gnu: tensorflow-lite: Update to 2.14.0.
* gnu/packages/patches/tensorflow-lite-unbundle.patch: Remove it. * gnu/local.mk: De-register patch. * gnu/packages/machine-learning.scm (tensorflow-lite): Update to 2.14.0. [source]: De-register patch. [inputs]: Improve style. Add python-ml-dtypes. Replace flatbuffers-23.1 by flatbuffers-23.5. [arguments]<#:configure-flags>: Refresh them. <#:phases>: Add phases 'unbundle and 'gemmlowp-fix. Refresh phases 'install-extra and 'copy-sources. * gnu/packages/serialization.scm (flatbuffers-23.5): Update comment. Change-Id: Ifeadfaa9173df4e0be08ce4f0dc13a4cd5297c0e Signed-off-by: Andreas Enge <andreas@enge.fr>
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/machine-learning.scm88
-rw-r--r--gnu/packages/patches/tensorflow-lite-unbundle.patch27
-rw-r--r--gnu/packages/serialization.scm2
4 files changed, 52 insertions, 66 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index f4527466e5..bedab4dcf2 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2331,7 +2331,6 @@ dist_patch_DATA = \
%D%/packages/patches/tcsh-fix-autotest.patch \
%D%/packages/patches/teensy-loader-cli-help.patch \
%D%/packages/patches/tensorflow-c-api-fix.patch \
- %D%/packages/patches/tensorflow-lite-unbundle.patch \
%D%/packages/patches/texinfo-headings-single.patch \
%D%/packages/patches/texinfo-5-perl-compat.patch \
%D%/packages/patches/telegram-desktop-allow-disable-libtgvoip.patch \
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 82fa0cd574..264fde6cfc 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -3194,7 +3194,7 @@ Python.")
(define-public tensorflow-lite
(package
(name "tensorflow-lite")
- (version "2.13.1")
+ (version "2.14.0")
(source
(origin
(method git-fetch)
@@ -3204,8 +3204,7 @@ Python.")
(file-name (git-file-name name version))
(sha256
(base32
- "09mfskmpvpbq919wibnw3bnhi1y3hkx3qrzm72gdr0gsivn1yb3w"))
- (patches (search-patches "tensorflow-lite-unbundle.patch"))))
+ "07f4x4g3kwhfjz7iadhqrv97zmw0blacixvca1gdqkqqi7aipxis"))))
(build-system cmake-build-system)
(arguments
(list
@@ -3226,6 +3225,7 @@ Python.")
"-DTFLITE_ENABLE_RUY=ON"
"-DTFLITE_ENABLE_XNNPACK=ON"
+ "-DSYSTEM_PTHREADPOOL=ON"
;; TODO: turn on Farmhash
;;"-DSYSTEM_FARMHASH=ON"
(string-append "-Dabsl_DIR=" #$(this-package-input "abseil-cpp")
@@ -3241,8 +3241,11 @@ Python.")
"/share/cpuinfo")
(string-append "-Druy_DIR=" #$(this-package-input "ruy")
"/lib/cmake/ruy")
+ (string-append "-DML_DTYPES_LIBRARY_DIRS="
+ #$(this-package-input "python-ml-dtypes") "/lib")
;; Don't fetch the sources. We have these already
+ "-Dml_dtypes_POPULATED=ON"
"-Dgemmlowp_POPULATED=TRUE"
"-Degl_headers_POPULATED=TRUE"
"-Dfp16_headers_POPULATED=TRUE"
@@ -3262,22 +3265,28 @@ Python.")
#~(modify-phases %standard-phases
(add-after 'unpack 'chdir
(lambda _ (chdir "tensorflow/lite")))
+ (add-after 'chdir 'unbundle-gemmlowp
+ (lambda _
+ (call-with-output-file "tools/cmake/modules/gemmlowp.cmake"
+ (lambda (port)
+ (display "\
+add_library(gemmlowp INTERFACE IMPORTED)
+include_directories(\"${gemmlowp_ROOT}/include/gemmlowp\")" port)))
+ (call-with-output-file "tools/cmake/modules/ml_dtypes.cmake"
+ (lambda (port)
+ (display "\
+add_library(ml_dtypes INTERFACE IMPORTED)
+find_library(ML_DTYPES_LIBRARIES
+ NAMES ml_dtypes.so
+ PATHS \"${ML_DTYPES_LIBRARY_DIRS}\"
+ NO_DEFAULT_PATH)" port)))))
(add-after 'chdir 'copy-sources
(lambda* (#:key inputs #:allow-other-keys)
- ;; TODO: properly use Guix's pthreaqdpool. We are not using
- ;; pthreadpool because we are not enabling xnnpack
- (substitute* "CMakeLists.txt"
- (("if\\(NOT DEFINED PTHREADPOOL_SOURCE_DIR\\)")
- "if(false)"))
- (substitute* "CMakeLists.txt"
- (("if\\(NOT TARGET pthreadpool\\)")
- "if(false)"))
-
;; Don't fetch source code; we already have everything we need.
(substitute* '("tools/cmake/modules/fft2d.cmake"
"tools/cmake/modules/farmhash.cmake"
"tools/cmake/modules/gemmlowp.cmake")
- (("OverridableFetchContent_Populate.*") ""))
+ (("^ *OverridableFetchContent_Populate.*") ""))
(mkdir-p "/tmp/farmhash")
(with-directory-excursion "/tmp/farmhash"
@@ -3303,6 +3312,11 @@ Python.")
(lambda _ (substitute* "kernels/internal/spectrogram.cc"
(("#include <math.h>")
"#include <math.h>\n#include <cstdint>\n"))))
+ (add-after 'stdint-fix 'gemmlowp-fix
+ (lambda _
+ (substitute* "kernels/internal/common.h"
+ (("#include \"fixedpoint/fixedpoint\\.h\"")
+ "#include <fixedpoint/fixedpoint.h>"))))
(add-after 'build 'build-shared-library
(lambda* (#:key configure-flags #:allow-other-keys)
(mkdir-p "c")
@@ -3316,35 +3330,35 @@ Python.")
"-j" (number->string (parallel-job-count)))))
(add-after 'install 'install-extra
- (lambda* (#:key outputs #:allow-other-keys)
- (let* ((out (assoc-ref outputs "out"))
- (lib (string-append out "/lib"))
- (bin (string-append out "/bin")))
- (install-file "../build/c/libtensorflowlite_c.so" lib)
- (install-file "../build/tools/benchmark/benchmark_model" bin))))
+ (lambda _
+ (install-file "../build/c/libtensorflowlite_c.so"
+ (string-append #$output "/lib"))
+ (install-file "../build/tools/benchmark/benchmark_model"
+ (string-append #$output "/bin"))))
(replace 'check
(lambda* (#:key tests? #:allow-other-keys)
(when tests?
(invoke "ctest" "-L" "plain")))))))
(inputs
- `(("abseil-cpp" ,abseil-cpp)
- ("cpuinfo" ,cpuinfo)
- ("eigen" ,eigen)
- ("fp16" ,fp16)
- ("flatbuffers" ,flatbuffers-23.1)
- ("gemmlowp" ,gemmlowp)
- ("mesa-headers" ,mesa-headers)
- ("neon2sse" ,neon2sse)
- ("nsync" ,nsync)
- ("opencl-clhpp" ,opencl-clhpp)
- ("opencl-headers" ,opencl-headers)
- ("opencl-icd-loader" ,opencl-icd-loader)
- ("pthreadpool" ,pthreadpool)
- ("python" ,python)
- ("ruy" ,ruy)
- ("re2" ,re2)
- ("xnnpack" ,xnnpack)
- ("vulkan-headers" ,vulkan-headers)))
+ (list abseil-cpp
+ cpuinfo
+ eigen
+ fp16
+ flatbuffers-23.5
+ gemmlowp
+ mesa-headers
+ neon2sse
+ nsync
+ opencl-clhpp
+ opencl-headers
+ opencl-icd-loader
+ pthreadpool
+ python
+ python-ml-dtypes
+ ruy
+ re2
+ xnnpack
+ vulkan-headers))
(native-inputs
`(("pkg-config" ,pkg-config)
("googletest" ,googletest)
diff --git a/gnu/packages/patches/tensorflow-lite-unbundle.patch b/gnu/packages/patches/tensorflow-lite-unbundle.patch
deleted file mode 100644
index efd7d5bbc6..0000000000
--- a/gnu/packages/patches/tensorflow-lite-unbundle.patch
+++ /dev/null
@@ -1,27 +0,0 @@
-Disable local CMake build code for bundled 3rdparty components.
-
-diff --git a/tensorflow/lite/CMakeLists.txt b/tensorflow/lite/CMakeLists.txt
-index 0476170e075..90abea00e8c 100644
---- a/tensorflow/lite/CMakeLists.txt
-+++ b/tensorflow/lite/CMakeLists.txt
-@@ -564,7 +564,7 @@ set(_ALL_TFLITE_HDRS ${_ALL_TFLITE_SRCS})
- list(FILTER _ALL_TFLITE_HDRS INCLUDE REGEX ".*\\.h$")
- target_include_directories(tensorflow-lite
- PUBLIC $<BUILD_INTERFACE:${TENSORFLOW_SOURCE_DIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
-- ${CMAKE_BINARY_DIR}/gemmlowp
-+ ${gemmlowp_ROOT}/include/gemmlowp
- )
- target_link_libraries(tensorflow-lite
- PUBLIC
-diff --git a/tensorflow/lite/tools/cmake/modules/Findgemmlowp.cmake b/tensorflow/lite/tools/cmake/modules/Findgemmlowp.cmake
-index 70331ad0a69..a9bd8a0f3bd 100644
---- a/tensorflow/lite/tools/cmake/modules/Findgemmlowp.cmake
-+++ b/tensorflow/lite/tools/cmake/modules/Findgemmlowp.cmake
-@@ -18,7 +18,6 @@
- include(gemmlowp)
- if(gemmlowp_POPULATED)
- set(GEMMLOWP_FOUND TRUE)
-- get_target_property(GEMMLOWP_INCLUDE_DIRS gemmlowp INTERFACE_DIRECTORIES)
- set(GEMMLOWP_LIBRARIES
- gemmlowp
- gemmlowp_fixedpoint
diff --git a/gnu/packages/serialization.scm b/gnu/packages/serialization.scm
index f5f5307249..2f40860491 100644
--- a/gnu/packages/serialization.scm
+++ b/gnu/packages/serialization.scm
@@ -932,7 +932,7 @@ game development and other performance-critical applications.")
(hidden-package
(package
(inherit flatbuffers)
- ;; needed explicitly by onnxruntime
+ ;; needed explicitly by onnxruntime and tensorflow-lite@2.14.0
(version "23.5.26")
(source
(origin