pkg/tensorflow-lite: add support to RIOT
This commit is contained in:
parent
2af88551e7
commit
2c3c967244
29
pkg/tensorflow-lite/Makefile
Normal file
29
pkg/tensorflow-lite/Makefile
Normal file
@ -0,0 +1,29 @@
|
||||
PKG_NAME=tensorflow-lite
|
||||
PKG_URL=https://github.com/tensorflow/tensorflow
|
||||
PKG_VERSION=1768c8f2fa155d4c6406e8ff7addf374c83de7ad
|
||||
PKG_LICENSE=Apache2.0
|
||||
|
||||
include $(RIOTBASE)/pkg/pkg.mk
|
||||
|
||||
TF_MODULES = tensorflow-lite-hello_world
|
||||
TF_USEMODULE = $(filter $(TF_MODULES),$(USEMODULE))
|
||||
|
||||
.PHONY: tensorflow-lite tensorflow-lite-%
|
||||
|
||||
CFLAGS += -Wno-pedantic
|
||||
CFLAGS += -DTF_LITE_STATIC_MEMORY
|
||||
CFLAGS += -DTF_LITE_USE_GLOBAL_ROUND
|
||||
|
||||
all: tensorflow-lite
|
||||
|
||||
tensorflow-lite: $(TF_USEMODULE)
|
||||
"$(MAKE)" -C $(PKG_BUILDDIR)/tensorflow/lite/c -f $(CURDIR)/Makefile.$(PKG_NAME)-c
|
||||
"$(MAKE)" -C $(PKG_BUILDDIR)/tensorflow/lite/core/api -f $(CURDIR)/Makefile.$(PKG_NAME)-core
|
||||
"$(MAKE)" -C $(PKG_BUILDDIR)/tensorflow/lite/kernels -f $(CURDIR)/Makefile.$(PKG_NAME)-kernels
|
||||
"$(MAKE)" -C $(PKG_BUILDDIR)/tensorflow/lite/kernels/internal -f $(CURDIR)/Makefile.$(PKG_NAME)-kernels-internal
|
||||
"$(MAKE)" -C $(PKG_BUILDDIR)/tensorflow/lite/micro/kernels -f $(CURDIR)/Makefile.$(PKG_NAME)-micro-kernels
|
||||
"$(MAKE)" -C $(PKG_BUILDDIR)/tensorflow/lite/micro/memory_planner -f $(CURDIR)/Makefile.$(PKG_NAME)-memory
|
||||
"$(MAKE)" -C $(PKG_BUILDDIR)/tensorflow/lite/micro -f $(CURDIR)/Makefile.$(PKG_NAME)
|
||||
|
||||
tensorflow-lite-%:
|
||||
"$(MAKE)" -C $(PKG_BUILDDIR)/tensorflow/lite/micro/examples/$* -f $(CURDIR)/Makefile.$(PKG_NAME)-$*
|
||||
12
pkg/tensorflow-lite/Makefile.dep
Normal file
12
pkg/tensorflow-lite/Makefile.dep
Normal file
@ -0,0 +1,12 @@
|
||||
USEMODULE += cpp11-compat
|
||||
|
||||
USEPKG += flatbuffers
|
||||
USEPKG += gemmlowp
|
||||
|
||||
USEMODULE += tensorflow-lite
|
||||
USEMODULE += tensorflow-lite-c
|
||||
USEMODULE += tensorflow-lite-core
|
||||
USEMODULE += tensorflow-lite-kernels
|
||||
USEMODULE += tensorflow-lite-kernels-internal
|
||||
USEMODULE += tensorflow-lite-memory
|
||||
USEMODULE += tensorflow-lite-micro-kernels
|
||||
1
pkg/tensorflow-lite/Makefile.include
Normal file
1
pkg/tensorflow-lite/Makefile.include
Normal file
@ -0,0 +1 @@
|
||||
INCLUDES += -I$(PKGDIRBASE)/tensorflow-lite
|
||||
12
pkg/tensorflow-lite/Makefile.tensorflow-lite
Normal file
12
pkg/tensorflow-lite/Makefile.tensorflow-lite
Normal file
@ -0,0 +1,12 @@
|
||||
MODULE = tensorflow-lite
|
||||
|
||||
CXXEXFLAGS += -Wno-sign-compare
|
||||
CXXEXFLAGS += -Wno-strict-aliasing
|
||||
CXXEXFLAGS += -Wno-type-limits
|
||||
CXXEXFLAGS += -Wno-unused-parameter
|
||||
CXXEXFLAGS += -Wno-unused-variable
|
||||
|
||||
SRCXXEXT = cc
|
||||
SRCXXEXCLUDE = $(wildcard *_test.$(SRCXXEXT))
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
9
pkg/tensorflow-lite/Makefile.tensorflow-lite-c
Normal file
9
pkg/tensorflow-lite/Makefile.tensorflow-lite-c
Normal file
@ -0,0 +1,9 @@
|
||||
MODULE = tensorflow-lite-c
|
||||
|
||||
CFLAGS += -Wno-strict-prototypes
|
||||
CFLAGS += -Wno-old-style-definition
|
||||
|
||||
NO_AUTO_SRC = 1
|
||||
SRC = common.c
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
17
pkg/tensorflow-lite/Makefile.tensorflow-lite-core
Normal file
17
pkg/tensorflow-lite/Makefile.tensorflow-lite-core
Normal file
@ -0,0 +1,17 @@
|
||||
MODULE = tensorflow-lite-core
|
||||
|
||||
CXXEXFLAGS += -Wno-sign-compare
|
||||
CXXEXFLAGS += -Wno-type-limits
|
||||
|
||||
SRCXXEXT = cc
|
||||
SRCXXEXCLUDE = $(wildcard *_test.$(SRCXXEXT))
|
||||
|
||||
NO_AUTO_SRC = 1
|
||||
SRCXX = \
|
||||
error_reporter.cc \
|
||||
flatbuffer_conversions.cc \
|
||||
op_resolver.cc \
|
||||
tensor_utils.cc \
|
||||
#
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
17
pkg/tensorflow-lite/Makefile.tensorflow-lite-hello_world
Normal file
17
pkg/tensorflow-lite/Makefile.tensorflow-lite-hello_world
Normal file
@ -0,0 +1,17 @@
|
||||
MODULE = tensorflow-lite-hello_world
|
||||
|
||||
CXXEXFLAGS += -Wno-type-limits
|
||||
CXXEXFLAGS += -Wno-unused-parameter
|
||||
|
||||
SRCXXEXT = cc
|
||||
SRCXXEXCLUDE = $(wildcard *_test.$(SRCXXEXT))
|
||||
|
||||
NO_AUTO_SRC = 1
|
||||
SRCXX = \
|
||||
constants.cc \
|
||||
main_functions.cc \
|
||||
output_handler.cc \
|
||||
sine_model_data.cc \
|
||||
#
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
12
pkg/tensorflow-lite/Makefile.tensorflow-lite-kernels
Normal file
12
pkg/tensorflow-lite/Makefile.tensorflow-lite-kernels
Normal file
@ -0,0 +1,12 @@
|
||||
MODULE = tensorflow-lite-kernels
|
||||
|
||||
CXXEXFLAGS += -Wno-missing-field-initializers
|
||||
CXXEXFLAGS += -Wno-unused-function
|
||||
CXXEXFLAGS += -Wno-unused-parameter
|
||||
|
||||
SRCXXEXT = cc
|
||||
|
||||
NO_AUTO_SRC = 1
|
||||
SRCXX = kernel_util.cc
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
@ -0,0 +1,12 @@
|
||||
MODULE = tensorflow-lite-kernels-internal
|
||||
|
||||
CXXEXFLAGS += -Wno-missing-field-initializers
|
||||
CXXEXFLAGS += -Wno-unused-function
|
||||
CXXEXFLAGS += -Wno-unused-parameter
|
||||
|
||||
SRCXXEXT = cc
|
||||
|
||||
NO_AUTO_SRC = 1
|
||||
SRCXX = quantization_util.cc
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
9
pkg/tensorflow-lite/Makefile.tensorflow-lite-memory
Normal file
9
pkg/tensorflow-lite/Makefile.tensorflow-lite-memory
Normal file
@ -0,0 +1,9 @@
|
||||
MODULE = tensorflow-lite-memory
|
||||
|
||||
CXXEXFLAGS += -Wno-sign-compare
|
||||
CXXEXFLAGS += -Wno-unused-parameter
|
||||
|
||||
SRCXXEXT = cc
|
||||
SRCXXEXCLUDE = $(wildcard *_test.$(SRCXXEXT))
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
15
pkg/tensorflow-lite/Makefile.tensorflow-lite-micro-kernels
Normal file
15
pkg/tensorflow-lite/Makefile.tensorflow-lite-micro-kernels
Normal file
@ -0,0 +1,15 @@
|
||||
MODULE = tensorflow-lite-micro-kernels
|
||||
|
||||
CXXEXFLAGS += -Wno-missing-field-initializers
|
||||
CXXEXFLAGS += -Wno-strict-overflow
|
||||
CXXEXFLAGS += -Wno-type-limits
|
||||
CXXEXFLAGS += -Wno-unused-parameter
|
||||
|
||||
ifeq (llvm,$(TOOLCHAIN))
|
||||
CXXEXFLAGS += -Wno-unused-const-variable
|
||||
endif
|
||||
|
||||
SRCXXEXT = cc
|
||||
SRCXXEXCLUDE = $(wildcard *_test.$(SRCXXEXT))
|
||||
|
||||
include $(RIOTBASE)/Makefile.base
|
||||
7
pkg/tensorflow-lite/doc.txt
Normal file
7
pkg/tensorflow-lite/doc.txt
Normal file
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* @defgroup pkg_tensorflow-lite TensorFlow Lite
|
||||
* @ingroup pkg
|
||||
* @brief Provides a RIOT support for TensorFlow Lite AI library
|
||||
*
|
||||
* @see https://www.tensorflow.org/lite/microcontrollers
|
||||
*/
|
||||
33
pkg/tensorflow-lite/patches/0001-global-round.patch
Normal file
33
pkg/tensorflow-lite/patches/0001-global-round.patch
Normal file
@ -0,0 +1,33 @@
|
||||
From e7d7acc96975ac47038fb7215925d4324b20aa86 Mon Sep 17 00:00:00 2001
|
||||
From: Alexandre Abadie <alexandre.abadie@inria.fr>
|
||||
Date: Tue, 17 Dec 2019 11:53:05 +0100
|
||||
Subject: [PATCH] use global round function
|
||||
|
||||
---
|
||||
tensorflow/lite/kernels/internal/reference/concatenation.h | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/tensorflow/lite/kernels/internal/reference/concatenation.h b/tensorflow/lite/kernels/internal/reference/concatenation.h
|
||||
index f587cfd1c9..3767112738 100644
|
||||
--- a/tensorflow/lite/kernels/internal/reference/concatenation.h
|
||||
+++ b/tensorflow/lite/kernels/internal/reference/concatenation.h
|
||||
@@ -19,6 +19,7 @@ limitations under the License.
|
||||
#include "tensorflow/lite/kernels/internal/common.h"
|
||||
#include "tensorflow/lite/kernels/internal/compatibility.h"
|
||||
#include "tensorflow/lite/kernels/internal/types.h"
|
||||
+#include "tensorflow/lite/kernels/internal/round.h"
|
||||
|
||||
namespace tflite {
|
||||
namespace reference_ops {
|
||||
@@ -122,7 +123,7 @@ inline void ConcatenationWithScaling(const ConcatenationParams& params,
|
||||
const float bias = -input_zeropoint[i] * scale;
|
||||
for (int j = 0; j < copy_size; ++j) {
|
||||
const int32_t value =
|
||||
- static_cast<int32_t>(std::round(input_ptr[j] * scale + bias)) +
|
||||
+ static_cast<int32_t>(tflite::TfLiteRound(input_ptr[j] * scale + bias)) +
|
||||
output_zeropoint;
|
||||
output_ptr[j] = static_cast<uint8_t>(
|
||||
std::max<int32_t>(std::min<int32_t>(255, value), 0));
|
||||
--
|
||||
2.20.1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user