mirror of
https://codeberg.org/guix/guix.git
synced 2025-10-02 02:15:12 +00:00
gnu: tensorflow-lite: Add python output.
This output corresponds to the pypi "tflite-runtime" package. * gnu/packages/machine-learning.scm (tensorflow-lite): [outputs]: Add "python". [arguments]<#:imported-modules, #:modules>: Add pyproject modules. <#:phases>: Add 'build-python, 'install-python, 'add-install-to-pythonpath and 'python-sanity-check phases. [inputs]: Replace python by python-wrapper. Add zlib. [propagated-inputs]: Add python-numpy. [native-inputs]: Add pybind11, python-wheel, swig. Signed-off-by: Andreas Enge <andreas@enge.fr>
This commit is contained in:
parent
8f57e6c996
commit
a7451a7700
1 changed files with 44 additions and 5 deletions
|
@ -3206,12 +3206,16 @@ Python.")
|
|||
(base32
|
||||
"07f4x4g3kwhfjz7iadhqrv97zmw0blacixvca1gdqkqqi7aipxis"))))
|
||||
(build-system cmake-build-system)
|
||||
(outputs (list "out" "python"))
|
||||
(arguments
|
||||
(list
|
||||
#:build-type "Release"
|
||||
#:imported-modules (append %cmake-build-system-modules
|
||||
%pyproject-build-system-modules)
|
||||
#:modules '((ice-9 match)
|
||||
(guix build utils)
|
||||
(guix build cmake-build-system))
|
||||
(guix build cmake-build-system)
|
||||
((guix build pyproject-build-system) #:prefix py:))
|
||||
#:configure-flags
|
||||
#~(list
|
||||
;; "-DTFLITE_KERNEL_TEST=ON" ; TODO: build tests
|
||||
|
@ -3328,17 +3332,46 @@ find_library(ML_DTYPES_LIBRARIES
|
|||
(lambda _
|
||||
(invoke "cmake" "--build" "." "--target" "benchmark_model"
|
||||
"-j" (number->string (parallel-job-count)))))
|
||||
|
||||
(add-after 'build-benchmark-model 'build-python
|
||||
(lambda* (#:key configure-flags #:allow-other-keys)
|
||||
(let ((script (string-append "../lite/tools/pip_package/"
|
||||
"build_pip_package_with_cmake.sh")))
|
||||
(substitute* script
|
||||
(("\"\\$\\{TENSORFLOW_LITE_DIR\\}\"" all)
|
||||
(string-append "${CMAKE_ADDITIONAL_CONFIGURE_FLAGS} "
|
||||
all)))
|
||||
(setenv "BUILD_NUM_JOBS" (number->string (parallel-job-count)))
|
||||
(setenv "CMAKE_ADDITIONAL_CONFIGURE_FLAGS"
|
||||
(string-join configure-flags " "))
|
||||
(invoke "sh" script))))
|
||||
(add-after 'install 'install-extra
|
||||
(lambda _
|
||||
(install-file "../build/c/libtensorflowlite_c.so"
|
||||
(string-append #$output "/lib"))
|
||||
(install-file "../build/tools/benchmark/benchmark_model"
|
||||
(string-append #$output "/bin"))))
|
||||
(add-after 'install-extra 'install-python
|
||||
(lambda* (#:key inputs outputs #:allow-other-keys)
|
||||
(with-directory-excursion
|
||||
"../lite/tools/pip_package/gen/tflite_pip/python3"
|
||||
((assoc-ref py:%standard-phases 'install)
|
||||
#:inputs inputs
|
||||
#:outputs `(("out" . ,#$output:python))))))
|
||||
(replace 'check
|
||||
(lambda* (#:key tests? #:allow-other-keys)
|
||||
(when tests?
|
||||
(invoke "ctest" "-L" "plain")))))))
|
||||
(invoke "ctest" "-L" "plain"))))
|
||||
(add-after 'install-python 'add-install-to-pythonpath
|
||||
(lambda* (#:key inputs #:allow-other-keys)
|
||||
((assoc-ref py:%standard-phases 'add-install-to-pythonpath)
|
||||
#:inputs inputs
|
||||
#:outputs `(("out" . ,#$output:python)))))
|
||||
(add-after 'add-install-to-pythonpath 'python-sanity-check
|
||||
(lambda* (#:key tests? inputs #:allow-other-keys)
|
||||
((assoc-ref py:%standard-phases 'sanity-check)
|
||||
#:inputs `(("sanity-check.py" . ,#$(default-sanity-check.py))
|
||||
,@inputs)
|
||||
#:outputs `(("out" . ,#$output:python))))))))
|
||||
(inputs
|
||||
(list abseil-cpp
|
||||
cpuinfo
|
||||
|
@ -3353,15 +3386,21 @@ find_library(ML_DTYPES_LIBRARIES
|
|||
opencl-headers
|
||||
opencl-icd-loader
|
||||
pthreadpool
|
||||
python
|
||||
python-wrapper
|
||||
python-ml-dtypes
|
||||
ruy
|
||||
re2
|
||||
xnnpack
|
||||
vulkan-headers))
|
||||
vulkan-headers
|
||||
zlib))
|
||||
(propagated-inputs
|
||||
(list python-numpy))
|
||||
(native-inputs
|
||||
`(("pkg-config" ,pkg-config)
|
||||
("googletest" ,googletest)
|
||||
("pybind11" ,pybind11)
|
||||
("python-wheel" ,python-wheel)
|
||||
("swig" ,swig)
|
||||
("farmhash-src"
|
||||
,(let ((commit "816a4ae622e964763ca0862d9dbd19324a1eaf45"))
|
||||
(origin
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue