Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 205 additions & 0 deletions extra/tflite-runtime/APKBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
# Maintainer: Ethan Leir <eleir@qnx.com>
pkgname=tflite-runtime
_pkgname=tensorflow
pkgver=2.21.0_rc0
_pkgver=${pkgver/_/-}
pkgrel=0
_pthreadpool_ver=0e6ca13779b57d397a5ba6bfdcaa8a275bc8ea2e
_ruy_ver=master
_xnnpack_ver=25b42dfddb0ee22170d73ff0d4b333ea1e6edfeb
_eigen_ver=5.0.1
pkgdesc="TensorFlow Lite - High-performance ML & GenAI deployment on edge platforms"
url="https://ai.google.dev/edge/litert"
arch="all"
license="Apache-2.0"
depends="
abseil-cpp-status
abseil-cpp-raw-hash-set
abseil-cpp-synchronization
abseil-cpp-str-format-internal
abseil-cpp-strings
abseil-cpp-cord
abseil-cpp-leak-check
abseil-cpp-strerror
abseil-cpp-cordz-info
abseil-cpp-hashtablez-sampler
abseil-cpp-hash
abseil-cpp-raw-logging-internal
abseil-cpp-kernel-timeout-internal
abseil-cpp-stacktrace
abseil-cpp-time
abseil-cpp-tracing-internal
abseil-cpp-malloc-internal
abseil-cpp-base
abseil-cpp-spinlock-wait
abseil-cpp-int128
abseil-cpp-strings-internal
abseil-cpp-cord-internal
abseil-cpp-crc-cord-state
abseil-cpp-cordz-handle
abseil-cpp-city
abseil-cpp-time-zone
abseil-cpp-crc32c
abseil-cpp-crc-internal
xnnpack
cpuinfo
pthreadpool
ruy
"
makedepends="
clang
cmake
ninja
git
python3-dev
python3-gpep517
python3-numpy-dev
python3-setuptools
python3-wheel
python3-pybind11-dev
"
subpackages="
$pkgname-dbg
$pkgname-dev
python3-$pkgname:_py3
"
_cpuinfo_git_rev=0
_ruy_git_rev=0
source="${pkgname}-${pkgver}.tar.gz::https://github.com/tensorflow/tensorflow/archive/refs/tags/v$_pkgver.tar.gz
https://github.com/qnx-ports/cpuinfo/archive/refs/tags/qnx-tflite-r$_cpuinfo_git_rev.tar.gz
https://gitlab.com/libeigen/eigen/-/archive/$_eigen_ver/eigen-$_eigen_ver.tar.gz
https://github.com/google/pthreadpool/archive/$_pthreadpool_ver.zip
https://github.com/qnx-ports/ruy/archive/refs/tags/qnx-$_ruy_ver-r$_ruy_git_rev.tar.gz
https://github.com/google/XNNPACK/archive/$_xnnpack_ver.zip
no-export.patch
cpuinfo_patch
eigen_patch
pthreadpool_patch
ruy_patch
XNNPACK_patch
"
builddir="$srcdir/$_pkgname-$_pkgver"
_cpuinfo_builddir="${srcdir}/cpuinfo-qnx-tflite-r${_cpuinfo_git_rev}"
_eigen_builddir="${srcdir}/eigen-${_eigen_ver}"
_pthreadpool_builddir="$srcdir/pthreadpool-$_pthreadpool_ver"
_ruy_builddir="${srcdir}/ruy-qnx-${_ruy_ver}-r${_ruy_git_rev}"
_xnnpack_builddir="$srcdir/XNNPACK-$_xnnpack_ver"

_patch_dir="$srcdir/patches"

options="!check" # This does not work with v2.21.0-rc0

unpack() {
default_unpack

# Workaround for busybox bug.
cd $srcdir
for u in $source; do
local s
if is_remote "$u"; then
s="$SRCDEST/$(filename_from_uri $u)"
else
s="$startdir/$u"
fi
case "$s" in
*.zip)
msg "Unpacking $s..."
unzip -n -q "$s";;
esac
done
}

prepare() {
default_prepare

(cd $_cpuinfo_builddir && patch ${patch_args:--p1} -i "$srcdir/cpuinfo_patch")
(cd $_eigen_builddir && patch ${patch_args:--p1} -i "$srcdir/eigen_patch")
(cd $_pthreadpool_builddir && patch ${patch_args:--p1} -i "$srcdir/pthreadpool_patch")
(cd $_ruy_builddir && patch ${patch_args:--p1} -i "$srcdir/ruy_patch")
(cd $_xnnpack_builddir && patch ${patch_args:--p1} -i "$srcdir/XNNPACK_patch")
}

build() {
_python_include_dir="/usr/include/python3.14"
_numpy_include_dir=$(python3 -c "import numpy; print(numpy.get_include())")
_pybind11_include_dir=$(python3 -c "import pybind11; print (pybind11.get_include())")

# Reduce size of debug syms
CFLAGS="$CFLAGS -g1 -DFARMHASH_LITTLE_ENDIAN=1 -I$_python_include_dir -I$_numpy_include_dir -I$_pybind11_include_dir" \
CXXFLAGS="$CXXFLAGS -g1 -DFARMHASH_LITTLE_ENDIAN=1 -I$_python_include_dir -I$_numpy_include_dir -I$_pybind11_include_dir" \
CC=clang CXX=clang++ \
cmake3.5 -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DQNX=ON \
-DTFLITE_ENABLE_INSTALL=ON \
-DABSL_ENABLE_INSTALL=OFF \
-DRUY_ENABLE_INSTALL=OFF \
-DRUY_MINIMAL_BUILD=ON \
-DCPUINFO_BUILD_PKG_CONFIG=OFF \
-DEIGEN_BUILD_CMAKE_PACKAGE=OFF \
-DFLATBUFFERS_INSTALL=OFF \
-DTFLITE_ENABLE_XNNPACK=ON \
-DXNNPACK_ENABLE_ASSEMBLY=ON \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DTFLITE_KERNEL_TEST="$(want_check && echo ON || echo OFF)" \
-DQNX_PATCH_DIR=$_patch_dir \
-DTENSORFLOW_SOURCE_DIR=$builddir \
-DPTHREADPOOL_SOURCE_DIR=$_pthreadpool_builddir \
-DOVERRIDABLE_FETCH_CONTENT_cpuinfo_URL=$_cpuinfo_builddir \
-DOVERRIDABLE_FETCH_CONTENT_eigen_URL=$_eigen_builddir \
-DOVERRIDABLE_FETCH_CONTENT_pthreadpool_URL=$_pthreadpool_builddir \
-DOVERRIDABLE_FETCH_CONTENT_ruy_URL=$_ruy_builddir \
-DOVERRIDABLE_FETCH_CONTENT_xnnpack_URL=$_xnnpack_builddir \
-DOVERRIDABLE_FETCH_CONTENT_abseil-cpp_GIT_REPOSITORY=https://github.com/qnx-ports/abseil-cpp.git \
-DOVERRIDABLE_FETCH_CONTENT_abseil-cpp_GIT_TAG=qnx_20250814.1-r1 \
-DOVERRIDABLE_FETCH_CONTENT_farmhash_GIT_REPOSITORY=https://github.com/qnx-ports/farmhash.git \
-DOVERRIDABLE_FETCH_CONTENT_farmhash_GIT_TAG=qnx-tflite-r0 \
-DOVERRIDABLE_FETCH_CONTENT_google_benchmark_GIT_REPOSITORY=https://github.com/qnx-ports/benchmark.git \
-DOVERRIDABLE_FETCH_CONTENT_google_benchmark_GIT_TAG=qnx_v1.8.3-r0 \
tensorflow/lite
cmake3.5 --build build -t all -t _pywrap_tensorflow_interpreter_wrapper

# nto target is a hack to use a previous build of tflite, rather than build
# everything from scratch. It helps save time on self-hosted too.
BUILD_DIR=$builddir/build/python_loader \
CMAKE_BUILD_DIR=$builddir/build \
$builddir/tensorflow/lite/tools/pip_package/build_pip_package_with_cmake.sh nto
}

check() {
# I believe delegate tests are not expected to pass, so we skip them here,
# along with the tests that get built by subprojects.
cd build
ctest3.5 --label-regex "plain"
}

package() {
python3 -m installer -d "$pkgdir" \
$builddir/build/python_loader/dist/*.whl
DESTDIR="$pkgdir" cmake3.5 --install build
python3 -m compileall -fq "$pkgdir"/usr/lib/python*
}

_py3() {
pkgdesc="$pkgdesc (python modules)"
depends="$pkgname python3-numpy"

amove usr/lib/python3.*
}

sha512sums="
7983866adeceddd7c867d14f9bd40df899ead255214aea5a1ce62b2b39ddfb602b6f2e3efa6572893d2d472916e0d2206f4cd404094ef49a85ce5b3294e23748 tflite-runtime-2.21.0_rc0.tar.gz
ba8d913a97c7c31a2778b110ebc147a1da74e4d57babcbef206178572459d25c34f808c04dc7fc163cb050117ea1a5512ae5003ae719f837bc5499f70ff46429 qnx-tflite-r0.tar.gz
b337d3bc38440db190a8f1fbc4eabc0098e69fcc95bfba195fe039ffb942cae2a7f0153f3094f35fa26325750d1c62e20cccaf916a41f5c7f248ec5e5d30a942 eigen-5.0.1.tar.gz
db93e3fb726a2fe7a50e3f019e432c317958c9ccc0ef4a5cfdccd412e6ea6433b73cae3c0a511007524533f0ff795f84812fc86648957770c4d33fd77f378e0a 0e6ca13779b57d397a5ba6bfdcaa8a275bc8ea2e.zip
0fbc0d837e86ecad89b093622bfd0199df97e1ab482c27a9dab69e2579130d63066829c785272173e5f97d722fa6e8f8fc613f8b67b30aba798cd2fd1d5a1387 qnx-master-r0.tar.gz
ad7bad6bcae85e9772ebbc1b6d0ba0bf56064419ffca026ac3af736ab3a2d2191d455cb90f974931cec3ed6e189168a0af79454a340df8bc00a15d92c235a3dd 25b42dfddb0ee22170d73ff0d4b333ea1e6edfeb.zip
fb1ab5d5991770116504a4c99519d51b4fbdbb14519cc6aa970437e9a2b7f96df1e9362501c564bbf2b4e365a17d948e93c2d463b8ce1ea395ae55480ce929b9 no-export.patch
8bf1a384d89dbdd1de5aa672c57395044e0391015267146d5cb9dede4601ae4550baba4c66f509ee632dcfd717401993a4fbd2b9c40f40d5e46e51b8e10276ae cpuinfo_patch
df31ed689ffb5dad1920ce5841b178f616920b631dde60e3b7d727290c828187da191b18d1ca8999fb5a07f39cdb5589e4910aa8dbed3e323eec29e5c8ac5e5f eigen_patch
9e9d146e3c5787cdd97cdaed1246b13ccae7b1479794ba21e6a24c05d8227ecaa0ff9d228a33afe009e48ab96af88996f9b56ea147807aeae65bbc3b5715ec96 pthreadpool_patch
c304a15f6c765e488382d76e5949cb4fc096a5397f9417d4e68afa5bc636f90bd82f78a4909bd9100488744dbeaba684251701272331a3283454d41861a5aa6c ruy_patch
f3c1ba3c6e841229c6affcc966fa3c7f9625fdb6d70ccf9d151184e85b1c023fb34e2a0bf20c1b022b78d1ce10445f9a7eb29fb7f02c818f47246bc5bb051257 XNNPACK_patch
"
27 changes: 27 additions & 0 deletions extra/tflite-runtime/XNNPACK_patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 66d38d3484..ea14e16548 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -389,7 +389,7 @@ ENDIF()
# ---[ Build flags
IF(NOT CMAKE_SYSTEM_NAME)
MESSAGE(FATAL_ERROR "CMAKE_SYSTEM_NAME not defined")
-ELSEIF(NOT CMAKE_SYSTEM_NAME MATCHES "^(Android|Darwin|iOS|Linux|Windows|CYGWIN|MSYS|QURT|Emscripten)$")
+ELSEIF(NOT CMAKE_SYSTEM_NAME MATCHES "^(Android|Darwin|iOS|Linux|Windows|CYGWIN|MSYS|QURT|Emscripten|QNX)$")
MESSAGE(FATAL_ERROR "Unrecognized CMAKE_SYSTEM_NAME value \"${CMAKE_SYSTEM_NAME}\"")
ENDIF()
IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
@@ -1313,13 +1313,6 @@ IF(XNNPACK_BUILD_LIBRARY)
TARGET_LINK_LIBRARIES(XNNPACK PRIVATE fxdiv)
ENDIF()

-IF(XNNPACK_BUILD_LIBRARY)
- INSTALL(TARGETS XNNPACK xnnpack-microkernels-prod
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-ENDIF()
-
# ---[ Configure KleidiAI
IF(XNNPACK_ENABLE_KLEIDIAI)
IF(NOT TARGET kleidiai)
23 changes: 23 additions & 0 deletions extra/tflite-runtime/cpuinfo_patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 87c51f0..46e7f83 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -345,18 +345,6 @@ GET_FILENAME_COMPONENT(CONFIG_FILE_PATH ${CMAKE_CURRENT_BINARY_DIR}/cpuinfo-conf
CONFIGURE_PACKAGE_CONFIG_FILE(
cmake/cpuinfo-config.cmake.in ${CONFIG_FILE_PATH}
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME})
-INSTALL(FILES ${CONFIG_FILE_PATH}
- DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}) # cpuinfo_DIR ${prefix}/share/cpuinfo
-
-INSTALL(TARGETS cpuinfo
- EXPORT cpuinfo-targets
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
-
-INSTALL(EXPORT cpuinfo-targets
- NAMESPACE ${PROJECT_NAME}:: # IMPORTED cpuinfo::cpuinfo
- DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME})

# ---[ cpuinfo micro-benchmarks
IF(CPUINFO_SUPPORTED_PLATFORM AND CPUINFO_BUILD_BENCHMARKS)
99 changes: 99 additions & 0 deletions extra/tflite-runtime/eigen_patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 36912bcde..78c7f6121 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -222,24 +222,6 @@ set_target_properties (eigen PROPERTIES EXPORT_NAME Eigen)
# Install Rule Configuration.
#==============================================================================

-install(FILES
- signature_of_eigen3_matrix_library
- DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel
- )
-
-if(EIGEN_BUILD_PKGCONFIG)
- configure_file(eigen3.pc.in eigen3.pc @ONLY)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/eigen3.pc
- DESTINATION ${PKGCONFIG_INSTALL_DIR})
-endif()
-
-install(DIRECTORY Eigen DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
-# Replace the "Version" header file with the generated one.
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/Eigen/Version
- DESTINATION ${INCLUDE_INSTALL_DIR}/Eigen/ COMPONENT Devel)
-
-install(TARGETS eigen EXPORT Eigen3Targets)
-
if(EIGEN_BUILD_CMAKE_PACKAGE)
include (CMakePackageConfigHelpers)
configure_package_config_file (
diff --git a/blas/CMakeLists.txt b/blas/CMakeLists.txt
index 45488d73d..af4d7fef5 100644
--- a/blas/CMakeLists.txt
+++ b/blas/CMakeLists.txt
@@ -31,10 +31,6 @@ foreach(target IN LISTS EIGEN_BLAS_TARGETS)
endif()

add_dependencies(blas ${target})
- install(TARGETS ${target}
- RUNTIME DESTINATION bin
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib)
endforeach()

if(EIGEN_BUILD_TESTING)
diff --git a/lapack/CMakeLists.txt b/lapack/CMakeLists.txt
index d837fff96..e47704210 100644
--- a/lapack/CMakeLists.txt
+++ b/lapack/CMakeLists.txt
@@ -120,10 +120,6 @@ foreach(target IN LISTS EIGEN_LAPACK_TARGETS)
endif()
target_link_libraries(${target} Eigen3::Eigen)
add_dependencies(lapack ${target})
- install(TARGETS ${target}
- RUNTIME DESTINATION bin
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib)
endforeach()


diff --git a/unsupported/Eigen/CMakeLists.txt b/unsupported/Eigen/CMakeLists.txt
index 1517ba956..4883e9b09 100644
--- a/unsupported/Eigen/CMakeLists.txt
+++ b/unsupported/Eigen/CMakeLists.txt
@@ -21,11 +21,4 @@ set(Eigen_HEADERS
Splines
)

-install(FILES
- ${Eigen_HEADERS}
- DESTINATION ${INCLUDE_INSTALL_DIR}/unsupported/Eigen COMPONENT Devel
- )
-
-install(DIRECTORY src DESTINATION ${INCLUDE_INSTALL_DIR}/unsupported/Eigen COMPONENT Devel FILES_MATCHING PATTERN "*.h")
-
add_subdirectory(CXX11)
diff --git a/unsupported/Eigen/CXX11/CMakeLists.txt b/unsupported/Eigen/CXX11/CMakeLists.txt
index 385ed240c..42c43ad4b 100644
--- a/unsupported/Eigen/CXX11/CMakeLists.txt
+++ b/unsupported/Eigen/CXX11/CMakeLists.txt
@@ -1,8 +1 @@
set(Eigen_CXX11_HEADERS Tensor TensorSymmetry ThreadPool)
-
-install(FILES
- ${Eigen_CXX11_HEADERS}
- DESTINATION ${INCLUDE_INSTALL_DIR}/unsupported/Eigen/CXX11 COMPONENT Devel
- )
-
-install(DIRECTORY src DESTINATION ${INCLUDE_INSTALL_DIR}/unsupported/Eigen/CXX11 COMPONENT Devel FILES_MATCHING PATTERN "*.h")
diff --git a/unsupported/Eigen/src/EulerAngles/CMakeLists.txt b/unsupported/Eigen/src/EulerAngles/CMakeLists.txt
index 22088eb30..9cccfaf3b 100644
--- a/unsupported/Eigen/src/EulerAngles/CMakeLists.txt
+++ b/unsupported/Eigen/src/EulerAngles/CMakeLists.txt
@@ -1,6 +1 @@
file(GLOB Eigen_EulerAngles_SRCS "*.h")
-
-install(FILES
- ${Eigen_EulerAngles_SRCS}
- DESTINATION ${INCLUDE_INSTALL_DIR}/unsupported/Eigen/src/EulerAngles COMPONENT Devel
- )
Loading