Add configurations files.

Add configuration files of TFLite Micro, its dependent third-party libraries and CMSIS_NN.

Signed-off-by: renzhiyuan1 <renzhiyuan1@xiaomi.com>
This commit is contained in:
renzhiyuan1 2023-11-17 19:01:19 +08:00 committed by Xiang Xiao
parent bdfce937e9
commit 71cbcb2618
21 changed files with 823 additions and 0 deletions

View file

@ -0,0 +1,25 @@
############################################################################
# apps/mlearning/cmsis-nn/Kconfig
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
config MLEARNING_CMSIS_NN
bool "CMSIS_NN Library"
default n
---help---
Enable CMSIS_NN.

View file

@ -0,0 +1,25 @@
############################################################################
# apps/mlearning/cmsis/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
ifneq ($(CONFIG_MLEARNING_CMSIS_NN),)
CONFIGURED_APPS += $(APPDIR)/mlearning/cmsis-nn
CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/mlearning/cmsis-nn/cmsis-nn/Include
CXXFLAGS += ${INCDIR_PREFIX}$(APPDIR)/mlearning/cmsis-nn/cmsis-nn/Include
endif

View file

@ -0,0 +1,51 @@
############################################################################
# apps/mlearning/cmsis-nn/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(APPDIR)/Make.defs
CMSIS_NN = cmsis-nn/Source
CMSIS_NN_VER = bfc54edb61e873039ec0857cacc40df36b1d644e
cmsis-nn.zip:
$(Q) curl -L https://github.com/ARM-software/CMSIS-NN/archive/$(CMSIS_NN_VER).zip -o cmsis-nn.zip
$(Q) unzip -o cmsis-nn.zip
$(Q) mv CMSIS-NN-$(CMSIS_NN_VER) cmsis-nn
ifeq ($(wildcard cmsis-nn/.git),)
context:: cmsis-nn.zip
distclean::
$(call DELDIR, cmsis-nn)
$(call DELFILE, cmsis-nn.zip)
endif
CSRCS += $(wildcard $(CMSIS_NN)/ActivationFunctions/*.c)
CSRCS += $(wildcard $(CMSIS_NN)/BasicMathFunctions/*.c)
CSRCS += $(wildcard $(CMSIS_NN)/PoolingFunctions/*.c)
CSRCS += $(wildcard $(CMSIS_NN)/ConvolutionFunctions/*.c)
CSRCS += $(wildcard $(CMSIS_NN)/SVDFunctions/*.c)
CSRCS += $(wildcard $(CMSIS_NN)/FullyConnectedFunctions/*.c)
CSRCS += $(wildcard $(CMSIS_NN)/NNSupportFunctions/*.c)
CSRCS += $(wildcard $(CMSIS_NN)/ConcatenationFunctions/*.c)
CSRCS += $(wildcard $(CMSIS_NN)/SoftmaxFunctions/*.c)
CSRCS += $(CMSIS_NN)/LSTMFunctions/arm_lstm_unidirectional_s8_s16.c
CSRCS += $(CMSIS_NN)/ReshapeFunctions/arm_reshape_s8.c
include $(APPDIR)/Application.mk

View file

@ -0,0 +1,24 @@
############################################################################
# apps/mlearning/tflite-micro/Kconfig
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
config TFLITEMICRO
bool "TFLiteMicro"
default n
depends on SYSTEM_FLATBUFFERS && MATH_GEMMLOWP && MATH_KISSFFT && MATH_RUY

View file

@ -0,0 +1,23 @@
############################################################################
# apps/mlearning/tflite-micro/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
ifneq ($(CONFIG_TFLITEMICRO),)
CONFIGURED_APPS += $(APPDIR)/mlearning/tflite-micro
endif

View file

@ -0,0 +1,83 @@
############################################################################
# apps/mlearning/tflite-micro/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
include $(APPDIR)/Make.defs
TFLITE_MICRO_VER = main
TFLITE_MICRO_UNPACK = tflite-micro
tflite-micro.zip:
$(Q) curl -L https://github.com/tensorflow/tflite-micro/archive/refs/heads/$(TFLITE_MICRO_VER).zip -o tflite-micro.zip
$(Q) unzip -o tflite-micro.zip
$(Q) mv tflite-micro-$(TFLITE_MICRO_VER) tflite-micro
$(Q) patch -d $(TFLITE_MICRO_UNPACK) -p1 < tflite-micro.patch
# Download and unpack tarball if no git repo found
ifeq ($(wildcard tflite-micro/.git),)
context:: tflite-micro.zip
distclean::
$(call DELDIR, tflite-micro)
$(call DELFILE, tflite-micro.zip)
endif
CXXEXT := .cc
COMMON_FLAGS += -DTF_LITE_STATIC_MEMORY
COMMON_FLAGS += -DTF_LITE_DISABLE_X86_NEON
COMMON_FLAGS += -Wno-undef
COMMON_FLAGS += -Wno-shadow
SRC_FILES := $(wildcard $(APPDIR)/mlearning/tflite-micro/tflite-micro/tensorflow/lite/micro/kernels/*.cc)
ifeq ($(CONFIG_MLEARNING_CMSIS_NN),y)
COMMON_FLAGS += -DCMSIS_NN
COMMON_FLAGS += ${INCDIR_PREFIX}$(APPDIR)/mlearning/cmsis-nn/cmsis-nn
NEW_SRC_FILES := $(wildcard $(APPDIR)/mlearning/tflite-micro/tflite-micro/tensorflow/lite/micro/kernels/cmsis_nn/*.cc)
SRC_FILES := $(filter-out $(notdir $(NEW_SRC_FILES)), $(notdir $(SRC_FILES)))
SRC_FILES := $(addprefix $(APPDIR)/mlearning/tflite-micro/tflite-micro/tensorflow/lite/micro/kernels/, $(SRC_FILES))
SRC_FILES += $(NEW_SRC_FILES)
endif
COMMON_FLAGS += ${INCDIR_PREFIX}$(APPDIR)/math/gemmlowp/gemmlowp
COMMON_FLAGS += ${INCDIR_PREFIX}$(APPDIR)/math/ruy/ruy
COMMON_FLAGS += ${INCDIR_PREFIX}$(APPDIR)/math/kissfft/kissfft
COMMON_FLAGS += ${INCDIR_PREFIX}$(APPDIR)/mlearning/tflite-micro/tflite-micro
CFLAGS += ${COMMON_FLAGS}
CXXFLAGS += ${COMMON_FLAGS}
SRC_FILES += $(wildcard $(APPDIR)/mlearning/tflite-micro/tflite-micro/tensorflow/lite/c/*.cc)
SRC_FILES += $(wildcard $(APPDIR)/mlearning/tflite-micro/tflite-micro/tensorflow/lite/schema/*.cc)
SRC_FILES += $(wildcard $(APPDIR)/mlearning/tflite-micro/tflite-micro/tensorflow/lite/core/c/*.cc)
SRC_FILES += $(wildcard $(APPDIR)/mlearning/tflite-micro/tflite-micro/tensorflow/lite/kernels/*.cc)
SRC_FILES += $(wildcard $(APPDIR)/mlearning/tflite-micro/tflite-micro/tensorflow/lite/kernels/internal/optimized/*.cc)
SRC_FILES += $(wildcard $(APPDIR)/mlearning/tflite-micro/tflite-micro/tensorflow/lite/kernels/internal/reference/*.cc)
SRC_FILES += $(wildcard $(APPDIR)/mlearning/tflite-micro/tflite-micro/tensorflow/lite/kernels/internal/*.cc)
SRC_FILES += $(wildcard $(APPDIR)/mlearning/tflite-micro/tflite-micro/tensorflow/lite/core/api/*.cc)
SRC_FILES += $(wildcard $(APPDIR)/mlearning/tflite-micro/tflite-micro/tensorflow/lite/micro/arena_allocator/*.cc)
SRC_FILES += $(wildcard $(APPDIR)/mlearning/tflite-micro/tflite-micro/tensorflow/lite/micro/memory_planner/*.cc)
SRC_FILES += $(wildcard $(APPDIR)/mlearning/tflite-micro/tflite-micro/tensorflow/lite/micro/*.cc)
SRC_FILES += $(wildcard $(APPDIR)/mlearning/tflite-micro/tflite-micro/tensorflow/lite/micro/tflite_bridge/*.cc)
SRC_FILES := $(filter-out %test.cc, $(SRC_FILES))
CXXSRCS += $(SRC_FILES)
include $(APPDIR)/Application.mk

View file

@ -0,0 +1,14 @@
diff --git a/signal/src/circular_buffer.cc b/signal/src/circular_buffer.cc
index 7638d912..3261be56 100644
--- a/signal/src/circular_buffer.cc
+++ b/signal/src/circular_buffer.cc
@@ -19,7 +19,9 @@ limitations under the License.
#include <stdlib.h>
#include <string.h>
+#ifndef ASSERT
#define ASSERT assert
+#endif
namespace tflite {
namespace tflm_signal {