-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- a/tensorflow/lite/CMakeLists.txt | ||
+++ b/tensorflow/lite/CMakeLists.txt | ||
@@ -233,7 +233,7 @@ | ||
list(APPEND TFLITE_TARGET_PRIVATE_OPTIONS "-Wa,-mbig-obj") | ||
endif() | ||
endif() | ||
-if(CMAKE_SYSTEM_NAME MATCHES "Android") | ||
+if(FALSE) | ||
find_library(ANDROID_LOG_LIB log) | ||
list(APPEND TFLITE_TARGET_DEPENDENCIES | ||
log | ||
@@ -263,7 +263,7 @@ | ||
|
||
# Handle TFLite logging source. | ||
list(FILTER TFLITE_SRCS EXCLUDE REGEX ".*minimal_logging_.*\\.cc$") | ||
-if("${CMAKE_SYSTEM_NAME}" STREQUAL "Android") | ||
+if(FALSE) | ||
list(APPEND TFLITE_SRCS ${TFLITE_SOURCE_DIR}/minimal_logging_android.cc) | ||
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "iOS") | ||
list(APPEND TFLITE_SRCS ${TFLITE_SOURCE_DIR}/minimal_logging_ios.cc) | ||
--- a/tensorflow/lite/tools/benchmark/CMakeLists.txt | ||
+++ b/tensorflow/lite/tools/benchmark/CMakeLists.txt | ||
@@ -78,7 +78,6 @@ | ||
) | ||
endif() # _TFLITE_ENABLE_NNAPI | ||
list(APPEND TFLITE_BENCHMARK_LIBS | ||
- ${ANDROID_LOG_LIB} | ||
absl::strings | ||
) | ||
endif() # Android | ||
--- a/tensorflow/lite/tools/logging.h | ||
+++ b/tensorflow/lite/tools/logging.h | ||
@@ -27,7 +27,7 @@ | ||
#undef ERROR | ||
#endif | ||
|
||
-#ifdef __ANDROID__ | ||
+#if 0 | ||
#include <android/log.h> | ||
#endif | ||
|
||
@@ -53,7 +53,7 @@ | ||
if (should_log_) { | ||
// Also print log to logcat for android, as stderr will be hidden | ||
// in the app use case. | ||
-#ifdef __ANDROID__ | ||
+#if 0 | ||
switch (severity_) { | ||
case LogSeverity::INFO: | ||
__android_log_print(ANDROID_LOG_INFO, "tflite", "%s", |
22 changes: 22 additions & 0 deletions
22
packages/python-tflite-runtime/0002-include-neon2sse-for-xnnpack.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- a/tensorflow/lite/CMakeLists.txt | ||
+++ b/tensorflow/lite/CMakeLists.txt | ||
@@ -507,6 +507,11 @@ | ||
if(TFLITE_ENABLE_XNNPACK) | ||
find_package(fp16_headers REQUIRED) | ||
find_package(XNNPACK REQUIRED) | ||
+ set(XNNPACK_NEON_2_SSE "") | ||
+ if (NOT CMAKE_SYSTEM_PROCESSOR OR CMAKE_SYSTEM_PROCESSOR MATCHES "x86") | ||
+ find_package(NEON_2_SSE REQUIRED) | ||
+ list(APPEND XNNPACK_NEON_2_SSE NEON_2_SSE::NEON_2_SSE) | ||
+ endif() | ||
populate_tflite_source_vars("delegates/xnnpack" | ||
TFLITE_DELEGATES_XNNPACK_SRCS | ||
FILTER ".*(_test|_tester)\\.(cc|h)" | ||
@@ -533,6 +538,7 @@ | ||
flatbuffers::flatbuffers | ||
gemmlowp::gemmlowp | ||
ruy::ruy | ||
+ ${XNNPACK_NEON_2_SSE} | ||
) | ||
|
||
list(APPEND TFLITE_TARGET_PUBLIC_OPTIONS "-DTFLITE_KERNEL_USE_XNNPACK") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
TERMUX_PKG_HOMEPAGE=https://www.tensorflow.org/lite | ||
TERMUX_PKG_DESCRIPTION="TensorFlow Lite Python bindings" | ||
TERMUX_PKG_LICENSE="Apache-2.0" | ||
TERMUX_PKG_MAINTAINER="@termux" | ||
TERMUX_PKG_VERSION="2.18.0" | ||
TERMUX_PKG_SRCURL=git+https://github.com/tensorflow/tensorflow | ||
TERMUX_PKG_AUTO_UPDATE=true | ||
TERMUX_PKG_DEPENDS="python, python-numpy, python-pip" | ||
TERMUX_PKG_UPDATE_TAG_TYPE="latest-release" | ||
TERMUX_PKG_PYTHON_COMMON_DEPS="setuptools, wheel, pybind11" | ||
TERMUX_PKG_HOSTBUILD=true | ||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" | ||
-DTFLITE_HOST_TOOLS_DIR=$TERMUX_PKG_HOSTBUILD_DIR | ||
" | ||
|
||
termux_step_host_build() { | ||
termux_setup_cmake | ||
|
||
cmake "$TERMUX_PKG_SRCDIR"/tensorflow/lite | ||
cmake --build . --verbose -j $TERMUX_PKG_MAKE_PROCESSES -t flatbuffers-flatc | ||
} | ||
|
||
termux_step_pre_configure() { | ||
termux_setup_cmake | ||
termux_setup_ninja | ||
|
||
# Copied from tensorflow/lite/tools/pip_package/build_pip_package_with_cmake.sh | ||
export TENSORFLOW_DIR="$TERMUX_PKG_SRCDIR" | ||
local TENSORFLOW_LITE_DIR="$TENSORFLOW_DIR/tensorflow/lite" | ||
local TENSORFLOW_VERSION=$(grep "_VERSION = " "$TENSORFLOW_DIR/tensorflow/tools/pip_package/setup.py" | cut -d= -f2 | sed "s/[ '-]//g") | ||
export PACKAGE_VERSION="$TENSORFLOW_VERSION" | ||
export PROJECT_NAME="tflite_runtime" | ||
TFLITE_BUILD_DIR="$TERMUX_PKG_BUILDDIR/build-wheel" | ||
local BUILD_DIR="$TFLITE_BUILD_DIR" | ||
local PYTHON="$(command -v python)" | ||
local PYBIND11_INCLUDE=$($PYTHON -c "import pybind11; print (pybind11.get_include())") | ||
CPPFLAGS+=" -I$PYTHON_SITE_PKG/numpy/_core/include" | ||
CPPFLAGS+=" -I$PYBIND11_INCLUDE" | ||
CPPFLAGS+=" -I$TERMUX_PREFIX/include/python$TERMUX_PYTHON_VERSION" | ||
|
||
# Build source tree | ||
rm -rf "$BUILD_DIR" && mkdir -p "$BUILD_DIR/tflite_runtime" | ||
cp -r "$TENSORFLOW_LITE_DIR/tools/pip_package/debian" \ | ||
"$TENSORFLOW_LITE_DIR/tools/pip_package/MANIFEST.in" \ | ||
"$TENSORFLOW_LITE_DIR/python/interpreter_wrapper" \ | ||
"$BUILD_DIR" | ||
cp "$TENSORFLOW_LITE_DIR/tools/pip_package/setup_with_binary.py" "$BUILD_DIR/setup.py" | ||
cp "$TENSORFLOW_LITE_DIR/python/interpreter.py" \ | ||
"$TENSORFLOW_LITE_DIR/python/metrics/metrics_interface.py" \ | ||
"$TENSORFLOW_LITE_DIR/python/metrics/metrics_portable.py" \ | ||
"$BUILD_DIR/tflite_runtime" | ||
echo "__version__ = '$PACKAGE_VERSION'" >> "$BUILD_DIR/tflite_runtime/__init__.py" | ||
echo "__git_version__ = '$(git -C "$TENSORFLOW_DIR" describe)'" >> "$BUILD_DIR/tflite_runtime/__init__.py" | ||
|
||
TERMUX_PKG_SRCDIR_OLD="$TERMUX_PKG_SRCDIR" | ||
TERMUX_PKG_SRCDIR="$TERMUX_PKG_SRCDIR/tensorflow/lite" | ||
} | ||
|
||
termux_step_post_configure() { | ||
TERMUX_PKG_SRCDIR="$TERMUX_PKG_SRCDIR_OLD" | ||
} | ||
|
||
termux_step_make() { | ||
# Build python interpreter_wrapper | ||
cmake --build . -j $TERMUX_PKG_MAKE_PROCESSES -t _pywrap_tensorflow_interpreter_wrapper | ||
cp "$TERMUX_PKG_BUILDDIR/_pywrap_tensorflow_interpreter_wrapper.so" \ | ||
"$TFLITE_BUILD_DIR/tflite_runtime" | ||
|
||
# Build python wheel | ||
cd "$TFLITE_BUILD_DIR" | ||
python setup.py bdist_wheel | ||
} | ||
|
||
termux_step_make_install() { | ||
local _pyver="${TERMUX_PYTHON_VERSION//./}" | ||
local _wheel="tflite_runtime-${TERMUX_PKG_VERSION}-cp${_pyver}-cp${_pyver}-linux_${TERMUX_ARCH}.whl" | ||
pip install --no-deps --prefix="$TERMUX_PREFIX" "$TFLITE_BUILD_DIR/dist/${_wheel}" | ||
} |