From 0efe0f838a2e83dcd1d001f491e56f0ef302d0ca Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Fri, 8 Apr 2022 09:14:35 +0200 Subject: [PATCH] pkg/tflite-micro: add support for tflite-micro --- pkg/tflite-micro/Makefile | 43 ++++++++++++++++++ pkg/tflite-micro/Makefile.dep | 19 ++++++++ pkg/tflite-micro/Makefile.include | 8 ++++ pkg/tflite-micro/doc.txt | 11 +++++ ...01-fix-build-with-private-descriptor.patch | Bin 0 -> 1444 bytes pkg/tflite-micro/tflite-c.mk | 5 ++ pkg/tflite-micro/tflite-core-api.mk | 5 ++ .../tflite-kernels-internal-reference.mk | 5 ++ pkg/tflite-micro/tflite-kernels-internal.mk | 5 ++ pkg/tflite-micro/tflite-kernels.mk | 5 ++ pkg/tflite-micro/tflite-micro-kernels.mk | 6 +++ .../tflite-micro-memory-planner.mk | 6 +++ pkg/tflite-micro/tflite-micro.mk | 6 +++ pkg/tflite-micro/tflite-schema.mk | 5 ++ 14 files changed, 129 insertions(+) create mode 100644 pkg/tflite-micro/Makefile create mode 100644 pkg/tflite-micro/Makefile.dep create mode 100644 pkg/tflite-micro/Makefile.include create mode 100644 pkg/tflite-micro/doc.txt create mode 100644 pkg/tflite-micro/patches/0001-fix-build-with-private-descriptor.patch create mode 100644 pkg/tflite-micro/tflite-c.mk create mode 100644 pkg/tflite-micro/tflite-core-api.mk create mode 100644 pkg/tflite-micro/tflite-kernels-internal-reference.mk create mode 100644 pkg/tflite-micro/tflite-kernels-internal.mk create mode 100644 pkg/tflite-micro/tflite-kernels.mk create mode 100644 pkg/tflite-micro/tflite-micro-kernels.mk create mode 100644 pkg/tflite-micro/tflite-micro-memory-planner.mk create mode 100644 pkg/tflite-micro/tflite-micro.mk create mode 100644 pkg/tflite-micro/tflite-schema.mk diff --git a/pkg/tflite-micro/Makefile b/pkg/tflite-micro/Makefile new file mode 100644 index 0000000000..48923cf0b9 --- /dev/null +++ b/pkg/tflite-micro/Makefile @@ -0,0 +1,43 @@ +PKG_NAME=tflite-micro +PKG_URL=https://github.com/tensorflow/tflite-micro +PKG_VERSION=1501b574b74fd7877aba30aa9d8b667f41b139c3 # sync from 2022.04.07 +PKG_LICENSE=Apache 2.0 + +include $(RIOTBASE)/pkg/pkg.mk + +CFLAGS += -Wno-cast-align +CFLAGS += -Wno-maybe-uninitialized +CFLAGS += -Wno-pedantic +CFLAGS += -Wno-unused-parameter + +TFLITE_MODULES := \ + tflite-c \ + tflite-core-api \ + tflite-kernels \ + tflite-kernels-internal \ + tflite-kernels-internal-reference \ + tflite-micro \ + tflite-micro-kernels \ + tflite-micro-memory-planner \ + tflite-schema \ + # + +DIR_tflite-c := tensorflow/lite/c +DIR_tflite-core-api := tensorflow/lite/core/api +DIR_tflite-kernels := tensorflow/lite/kernels +DIR_tflite-kernels-internal := tensorflow/lite/kernels/internal +DIR_tflite-kernels-internal-reference := tensorflow/lite/kernels/internal/reference +DIR_tflite-micro := tensorflow/lite/micro +DIR_tflite-micro-kernels := tensorflow/lite/micro/kernels +DIR_tflite-micro-memory-planner := tensorflow/lite/micro/memory_planner +DIR_tflite-schema := tensorflow/lite/schema + +TFLITE_MODULES_USED := $(filter $(TFLITE_MODULES),$(USEMODULE)) + +all: $(TFLITE_MODULES_USED) + @: + +.PHONY: tflite-% + +tflite-%: + $(QQ)"$(MAKE)" -C $(PKG_SOURCE_DIR)/$(DIR_$@) -f $(CURDIR)/$@.mk diff --git a/pkg/tflite-micro/Makefile.dep b/pkg/tflite-micro/Makefile.dep new file mode 100644 index 0000000000..e2fa8f5d43 --- /dev/null +++ b/pkg/tflite-micro/Makefile.dep @@ -0,0 +1,19 @@ +FEATURES_REQUIRED += cpp +USEMODULE += cpp11-compat + +USEPKG += flatbuffers +USEPKG += gemmlowp +USEPKG += ruy + +USEMODULE += tflite-c +USEMODULE += tflite-core-api +USEMODULE += tflite-kernels +USEMODULE += tflite-kernels-internal +USEMODULE += tflite-kernels-internal-reference +USEMODULE += tflite-micro +USEMODULE += tflite-micro-kernels +USEMODULE += tflite-micro-memory-planner +USEMODULE += tflite-schema + +# This package doesn't work on riscv and mips +FEATURES_BLACKLIST += arch_mips32r2 arch_riscv diff --git a/pkg/tflite-micro/Makefile.include b/pkg/tflite-micro/Makefile.include new file mode 100644 index 0000000000..cab52a8d83 --- /dev/null +++ b/pkg/tflite-micro/Makefile.include @@ -0,0 +1,8 @@ +INCLUDES += -I$(PKGDIRBASE)/tflite-micro + +CFLAGS += -DTF_LITE_STATIC_MEMORY +CFLAGS += -DTF_LITE_DISABLE_X86_NEON +CFLAGS += -DTF_LITE_USE_GLOBAL_CMATH_FUNCTIONS +CFLAGS += -DTF_LITE_USE_GLOBAL_MIN +CFLAGS += -DTF_LITE_USE_GLOBAL_MAX +CFLAGS += -DFLATBUFFERS_LOCALE_INDEPENDENT=0 diff --git a/pkg/tflite-micro/doc.txt b/pkg/tflite-micro/doc.txt new file mode 100644 index 0000000000..7482f7cea8 --- /dev/null +++ b/pkg/tflite-micro/doc.txt @@ -0,0 +1,11 @@ +/** + * @defgroup pkg_tflite-micro Tensorflow Lite Micro + * @ingroup pkg + * @brief Portable C++ library for signal processing and machine learning inferencing + * + * # License + * + * Licensed under Apache 2.0. + * + * @see https://github.com/tensorflow/tflite-micro + */ diff --git a/pkg/tflite-micro/patches/0001-fix-build-with-private-descriptor.patch b/pkg/tflite-micro/patches/0001-fix-build-with-private-descriptor.patch new file mode 100644 index 0000000000000000000000000000000000000000..4e0fba20f4e3d2456d3ab93564506c6acfd89e01 GIT binary patch literal 1444 zcmbu9QE!_t6oudYEAC^v1Tc_5LZ_+GO1DalR<&98Fiptd>)?rCWSpc`+x_;LG+Wm# zt11N{kS@N*NB+*`RI3FHa2y9=o+B52=*Jw3fDXcOTtsmki!l`D#QSSY4y`<{FXTX3wi`3HK1d3nHCVhFU9~X>61> zsBP2V*FA(*#99fg=?YsYN>tvFLi0TMQlcqQ+h7TSx`mRh5OTyC80W~Lm34t&mw?^KKo=ia zGfR|J#j>*b<8G&vD^)>lBb6DI{r;9IAzCzTc0?TF0L)Ia^Rro+U8d7d*J*Zrb~*bz zInPeg^K_OHcsS~8J#2i{Y=LdVy1hl0;#VbQcRK%j>N}TjlRz=dX%V`vKVp=R#;;1k zZowDH?{4Wx52F4UdiMDT=MBoV8^6o#^gUsIUbcj{{F9E)kAFK44neK#C`*oT_s}hp xwSh<7gTfA|>Bd&S0ipDQnLeyoR!LiBdfq