28 Commits

Author SHA1 Message Date
Alin Jerpelea
7220a3bf48 mlearning: migrate to SPDX identifier
Most tools used for compliance and SBOM generation use SPDX identifiers
This change brings us a step closer to an easy SBOM generation.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
2024-12-21 13:53:10 +08:00
chao an
d6f6f5ce11 mlearning/tflite-micro: fix build break if enable cmsis-nn and neon
Signed-off-by: chao an <anchao@lixiang.com>
2024-12-19 02:00:48 +08:00
chao an
9c5a2ad062 mlearning/tflite-micro: add a config option to redirect micro log to syslog
new config option TFLITEMICRO_SYSLOG to redirect micro log to syslog

Signed-off-by: chao an <anchao@lixiang.com>
2024-12-10 18:11:27 +08:00
chao an
37acd5e671 mlearning: fix build break if enable cmsis-nn
apps/mlearning/tflite-micro/tflite-micro/tensorflow/lite/micro/kernels/cmsis_nn/conv.cc:18:10:
  fatal error: Include/arm_nnfunctions.h: No such file or directory
   18 | #include "Include/arm_nnfunctions.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: chao an <anchao@lixiang.com>
2024-12-09 17:29:05 +08:00
chao an
296d5d15af tflm: add tflm hello world example into nuttx build
1. add tflm hello world example into nuttx build
2. add tflm model convert flow

Test on sim/tflm

$ cmake -B build -DBOARD_CONFIG=sim/tflm -GNinja
$ cmake --build build
$ ./build/nuttx

NuttShell (NSH) NuttX-10.4.0
nsh> tflm_hello
0 (id=0): size=16, offset=0, first_used=0 last_used=1
1 (id=1): size=64, offset=64, first_used=1 last_used=2
2 (id=2): size=64, offset=0, first_used=2 last_used=3
3 (id=3): size=16, offset=64, first_used=3 last_used=3
 0: 0000000000...................................................................... (1k)
 1: 0000000000..............................1111111111111111111111111111111111111111 (1k)
 2: 22222222222222222222222222222222222222221111111111111111111111111111111111111111 (1k)
 3: 22222222222222222222222222222222222222223333333333.............................. (1k)

"Unique Tag","Total ticks across all events with that tag."
FULLY_CONNECTED, 0
"total number of ticks", 0

[RecordingMicroAllocator] Arena allocation total 2344 bytes
[RecordingMicroAllocator] Arena allocation head 128 bytes
[RecordingMicroAllocator] Arena allocation tail 2216 bytes
[RecordingMicroAllocator] 'TfLiteEvalTensor data' used 240 bytes with alignment overhead (requested 240 bytes for 10 allocations)
[RecordingMicroAllocator] 'Persistent TfLiteTensor data' used 128 bytes with alignment overhead (requested 128 bytes for 2 tensors)
[RecordingMicroAllocator] 'Persistent buffer data' used 1152 bytes with alignment overhead (requested 1100 bytes for 7 allocations)
[RecordingMicroAllocator] 'NodeAndRegistration struct' used 192 bytes with alignment overhead (requested 192 bytes for 3 NodeAndRegistration structs)
0 (id=0): size=16, offset=0, first_used=0 last_used=1
1 (id=1): size=64, offset=64, first_used=1 last_used=2
2 (id=2): size=64, offset=0, first_used=2 last_used=3
3 (id=3): size=16, offset=64, first_used=3 last_used=3
 0: 0000000000...................................................................... (1k)
 1: 0000000000..............................1111111111111111111111111111111111111111 (1k)
 2: 22222222222222222222222222222222222222221111111111111111111111111111111111111111 (1k)
 3: 22222222222222222222222222222222222222223333333333.............................. (1k)
0 (id=0): size=16, offset=16, first_used=0 last_used=1
1 (id=1): size=16, offset=0, first_used=1 last_used=2
2 (id=2): size=16, offset=16, first_used=2 last_used=3
3 (id=3): size=16, offset=0, first_used=3 last_used=3
 0: ................0000000000000000................................................ (1k)
 1: 11111111111111110000000000000000................................................ (1k)
 2: 11111111111111112222222222222222................................................ (1k)
 3: 33333333333333332222222222222222................................................ (1k)
~~~ALL TESTS PASSED~~~

nsh>

Signed-off-by: chao an <anchao@lixiang.com>
2024-12-02 13:33:55 +08:00
chao an
8b253d699c mlearning/tflite-micro: add tflm tool into cmake build
Signed-off-by: chao an <anchao@lixiang.com>
2024-12-01 10:14:49 +08:00
chao an
5cb1cc7ac7 mlearning/tflite-micro: correct include patch of support library
1. correct include patch of support library
2. add flatbuffers include path

Signed-off-by: chao an <anchao@lixiang.com>
2024-12-01 10:14:49 +08:00
chao an
8bc824a5e7 system/tflite-micro: fix patch flow of tflite-micro
Signed-off-by: chao an <anchao@lixiang.com>
2024-12-01 10:14:49 +08:00
jihandong
25937282ed ml: follow nxstyle
Signed-off-by: jihandong <jihandong@xiaomi.com>
2024-10-18 09:40:17 +08:00
jihandong
7d87768f78 ml: a cmdline tool to use tflite-micro.
Signed-off-by: jihandong <jihandong@xiaomi.com>
2024-10-18 09:40:17 +08:00
jihandong
b91adbb9f2 ml: useful tflm debug options
print memory plan, and time cost of each operators.

Signed-off-by: jihandong <jihandong@xiaomi.com>
2024-10-18 09:40:17 +08:00
jihandong
f2eb5cd3c4 ml: tflite extra hardware support.
Signed-off-by: jihandong <jihandong@xiaomi.com>
2024-10-18 09:40:17 +08:00
jihandong
b15e71cd22 ml: update Makefile
-O3: reduce code size.
-DTF_LITE_STATIC_MEMORY: cause bugs on some cores.
+DTFLITE_EMULATE_FLOAT: robuster to emulate float cucalation by fix-point.
Signed-off-by: jihandong <jihandong@xiaomi.com>
2024-10-18 09:40:17 +08:00
jihandong
c585aa147a ml: clean tflite Makefile
Signed-off-by: jihandong <jihandong@xiaomi.com>
2024-10-18 09:40:17 +08:00
xinhaiteng
958d8e03eb Modify the usage error of neon instruction set
The second argument of vgetq_lane_s32(__a, __b) needs to be initialized before compilation, so unroll the for loop. and correct the passed parameters.

Signed-off-by: xinhaiteng <xinhaiteng@xiaomi.com>
2024-10-18 09:40:17 +08:00
renzhiyuan1
eb56c62dc9 cmake:add tflite-micro CMake build
Signed-off-by: renzhiyuan1 <renzhiyuan1@xiaomi.com>
2024-10-18 09:40:17 +08:00
xinhaiteng
dda8cab335 ml: tflm mean optimization patch
Separate the Int8 implementation of the 'mean' operator to reduce the code size.

Signed-off-by: xinhaiteng <xinhaiteng@xiaomi.com>
2024-10-18 09:40:17 +08:00
xinhaiteng
068b2b16bb ml: tflm quantize optimization patch
Separate the 'Float32 to Int8' implementation of the 'quantize' operator to reduce the code size.

Signed-off-by: xinhaiteng <xinhaiteng@xiaomi.com>
2024-10-18 09:40:17 +08:00
xinhaiteng
570102c501 delete the neon conv2D
The complete implementation is placed separately in mLearning/tflite-micro/operators/neon, delete this part.

Signed-off-by: xinhaiteng <xinhaiteng@xiaomi.com>
2024-10-18 09:40:17 +08:00
jihandong
14a591fab2 ml: tflm dequantize optimization patch
Signed-off-by: jihandong <jihandong@xiaomi.com>
2024-10-18 09:40:17 +08:00
xinhaiteng
67f495e360 Added Cortex-A compilation environment.
Cortex-A compilation options are added to tflite-micro and cmsis-nn, and new operator compilation environments are configured.

Signed-off-by: xinhaiteng <xinhaiteng@xiaomi.com>
2024-10-18 09:40:17 +08:00
xinhaiteng
11519fe1ca Update third-party library version
Tflite-micro, ruy and cmsis-nn need to be updated to a new version.
Signed-off-by: xinhaiteng <xinhaiteng@xiaomi.com>
2024-10-18 09:40:17 +08:00
xinhaiteng
fb17e33894 Neon optimized Add operator
VELAPLATFO-25411

On the basis of CMSIS-NN, neon was used to optimize the Add operator, which calculates the offset and addition of eight input and output data in one loop.

Signed-off-by: xinhaiteng <xinhaiteng@xiaomi.com>
2024-10-18 09:40:17 +08:00
xinhaiteng
a37ca36a8a Neon optimized Conv operator
Based on CMSIS-NN, the Conv operator was optimized. Using Neon acceleration, multiply 8 input data and 8 filter data in a single loop; Using Im2col technology, convert the output data into a matrix, calculate 2 rows of input data and 4 rows of filter data in a single large loop, and obtain 2x4 output data.

Signed-off-by: xinhaiteng <xinhaiteng@xiaomi.com>
2024-10-18 09:40:17 +08:00
xinhaiteng
754d9e39a8 TFLM Cortex-A NEON Conv
Use neon to accelerate the conv op, and the output results are the same.

Signed-off-by: xinhaiteng <xinhaiteng@xiaomi.com>
2024-10-18 09:40:17 +08:00
renzhiyuan1
71cbcb2618 Add configurations files.
Add configuration files of TFLite Micro, its dependent third-party libraries and CMSIS_NN.

Signed-off-by: renzhiyuan1 <renzhiyuan1@xiaomi.com>
2024-10-18 09:40:17 +08:00
dengwenqi
6b6e0783cf fix: git status/git status --ignore normalization check problem
Signed-off-by: dengwenqi <dengwenqi@xiaomi.com>
2024-10-18 09:40:17 +08:00
dengwenqi
06189b556c fix: git status/git status --ignore normalization check problem
Signed-off-by: dengwenqi <dengwenqi@xiaomi.com>
2024-10-18 09:40:17 +08:00