summaryrefslogtreecommitdiff
path: root/gnu/packages/machine-learning.scm
diff options
context:
space:
mode:
authorAndy Tai <atai@atai.org>2025-11-23 00:49:56 -0800
committerAndreas Enge <andreas@enge.fr>2025-12-04 21:09:52 +0100
commit9f80d52c2c00d907b9f3ea6589ca17dcc880ff88 (patch)
tree9d3c914202a6ccaaa4907d07723c51c6c5c29b5b /gnu/packages/machine-learning.scm
parentb68c3e66e23c08bcf9794d3a5a0313b3a714d13d (diff)
gnu: Add tflite-micro.
* gnu/packages/machine-learning.scm (tflite-micro): New variable. * gnu/packages/patches/tflite-micro_disable_download.patch: New file. * gnu/local.mk: (dist_patch_DATA): Reference new patch file. Change-Id: I43470f3101a48cf3570e31c00796d16e7257673c Signed-off-by: Andreas Enge <andreas@enge.fr>
Diffstat (limited to 'gnu/packages/machine-learning.scm')
-rw-r--r--gnu/packages/machine-learning.scm84
1 files changed, 84 insertions, 0 deletions
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index c53187220df..66861c67b4f 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -3521,6 +3521,90 @@ devices.")
(string-append #$output "/lib")))))
(native-inputs '())))
+(define-public tflite-micro
+ (let ((commit "a94423c6b6ee1f30c82d60952d70f749296a5581")
+ (version "0")
+ (revision "0"))
+ (package
+ (name "tflite-micro")
+ (version (git-version version revision commit))
+ (source
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/tensorflow/tflite-micro")
+ (commit commit)))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32 "0q1l4chj4p7vwclcysjmzl017l08kpqh498wpghq1cph641mdp5n"))
+ (patches (search-patches "tflite-micro_disable_download.patch"))))
+ (build-system gnu-build-system)
+ (arguments
+ (list
+ #:tests? #f ;there are no tests
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'patch-makefile
+ (lambda _
+ (let ((makefile "tensorflow/lite/micro/tools/make/Makefile"))
+ (substitute* makefile
+ (("BASE_GENDIR := gen")
+ "BASE_GENDIR := $(BUILD_DIR)")))))
+ (delete 'configure)
+
+ (replace 'build
+ (lambda _
+ (let ((makefile "tensorflow/lite/micro/tools/make/Makefile"))
+ (mkdir-p "../build")
+ (invoke "make"
+ "-j"
+ (number->string (parallel-job-count))
+ "-f"
+ makefile
+ (string-append "BASE_GENDIR=" "../build")
+ (string-append "PRE_INCLUDES=-I"
+ #$(this-package-input "gemmlowp")
+ "/include/gemmlowp"
+ " -I"
+ #$(this-package-input
+ "kissfft-for-tflite-micro")
+ "/include/kissfft"
+ " -I"
+ #$(package-source
+ kissfft-for-tflite-micro))))))
+ (replace 'install
+ (lambda _
+ (for-each (lambda (f)
+ (install-file f
+ (string-append #$output "/lib")))
+ (find-files "../build" "\\.a$"))
+ (for-each (lambda (f)
+ (install-file f
+ (string-append #$output
+ "/include/lite/micro")))
+ (find-files "tensorflow/lite/micro" "\\.h$"))
+ (for-each (lambda (f)
+ (install-file f
+ (string-append #$output
+ "/include/lite/micro")))
+ (find-files "signal/micro/kernels" "\\.h$"))
+ (for-each (lambda (f)
+ (install-file f
+ (string-append #$output
+ "/include/lite/micro")))
+ (find-files "signal/src" "\\.h$")))))))
+ (inputs (list flatbuffers-23.5 gemmlowp kissfft-for-tflite-micro ruy))
+ (native-inputs (list python python-pillow python-numpy))
+ (home-page "https://ai.google.dev/edge/litert/microcontrollers/overview")
+ (synopsis
+ "Infrastructure to enable deployment of ML models to embedded targets ")
+ (description
+ "TensorFlow Lite for Microcontrollers is a port of TensorFlow Lite designed
+to run machine learning models on DSPs, microcontrollers and other devices with
+limited memory.")
+ (license license:asl2.0))))
+
+
(define-public dmlc-core
(package
(name "dmlc-core")