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
|
(base32
|
||||||
"07f4x4g3kwhfjz7iadhqrv97zmw0blacixvca1gdqkqqi7aipxis"))))
|
"07f4x4g3kwhfjz7iadhqrv97zmw0blacixvca1gdqkqqi7aipxis"))))
|
||||||
(build-system cmake-build-system)
|
(build-system cmake-build-system)
|
||||||
|
(outputs (list "out" "python"))
|
||||||
(arguments
|
(arguments
|
||||||
(list
|
(list
|
||||||
#:build-type "Release"
|
#:build-type "Release"
|
||||||
|
#:imported-modules (append %cmake-build-system-modules
|
||||||
|
%pyproject-build-system-modules)
|
||||||
#:modules '((ice-9 match)
|
#:modules '((ice-9 match)
|
||||||
(guix build utils)
|
(guix build utils)
|
||||||
(guix build cmake-build-system))
|
(guix build cmake-build-system)
|
||||||
|
((guix build pyproject-build-system) #:prefix py:))
|
||||||
#:configure-flags
|
#:configure-flags
|
||||||
#~(list
|
#~(list
|
||||||
;; "-DTFLITE_KERNEL_TEST=ON" ; TODO: build tests
|
;; "-DTFLITE_KERNEL_TEST=ON" ; TODO: build tests
|
||||||
|
@ -3328,17 +3332,46 @@ find_library(ML_DTYPES_LIBRARIES
|
||||||
(lambda _
|
(lambda _
|
||||||
(invoke "cmake" "--build" "." "--target" "benchmark_model"
|
(invoke "cmake" "--build" "." "--target" "benchmark_model"
|
||||||
"-j" (number->string (parallel-job-count)))))
|
"-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
|
(add-after 'install 'install-extra
|
||||||
(lambda _
|
(lambda _
|
||||||
(install-file "../build/c/libtensorflowlite_c.so"
|
(install-file "../build/c/libtensorflowlite_c.so"
|
||||||
(string-append #$output "/lib"))
|
(string-append #$output "/lib"))
|
||||||
(install-file "../build/tools/benchmark/benchmark_model"
|
(install-file "../build/tools/benchmark/benchmark_model"
|
||||||
(string-append #$output "/bin"))))
|
(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
|
(replace 'check
|
||||||
(lambda* (#:key tests? #:allow-other-keys)
|
(lambda* (#:key tests? #:allow-other-keys)
|
||||||
(when tests?
|
(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
|
(inputs
|
||||||
(list abseil-cpp
|
(list abseil-cpp
|
||||||
cpuinfo
|
cpuinfo
|
||||||
|
@ -3353,15 +3386,21 @@ find_library(ML_DTYPES_LIBRARIES
|
||||||
opencl-headers
|
opencl-headers
|
||||||
opencl-icd-loader
|
opencl-icd-loader
|
||||||
pthreadpool
|
pthreadpool
|
||||||
python
|
python-wrapper
|
||||||
python-ml-dtypes
|
python-ml-dtypes
|
||||||
ruy
|
ruy
|
||||||
re2
|
re2
|
||||||
xnnpack
|
xnnpack
|
||||||
vulkan-headers))
|
vulkan-headers
|
||||||
|
zlib))
|
||||||
|
(propagated-inputs
|
||||||
|
(list python-numpy))
|
||||||
(native-inputs
|
(native-inputs
|
||||||
`(("pkg-config" ,pkg-config)
|
`(("pkg-config" ,pkg-config)
|
||||||
("googletest" ,googletest)
|
("googletest" ,googletest)
|
||||||
|
("pybind11" ,pybind11)
|
||||||
|
("python-wheel" ,python-wheel)
|
||||||
|
("swig" ,swig)
|
||||||
("farmhash-src"
|
("farmhash-src"
|
||||||
,(let ((commit "816a4ae622e964763ca0862d9dbd19324a1eaf45"))
|
,(let ((commit "816a4ae622e964763ca0862d9dbd19324a1eaf45"))
|
||||||
(origin
|
(origin
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue