Skip to content

Commit dab7e51

Browse files
committed
解决路径依赖问题, 调整了文件结构
1 parent 06025e6 commit dab7e51

File tree

338 files changed

+5886
-3392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

338 files changed

+5886
-3392
lines changed

README.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
## 1、介绍
66

7-
本软件包是针对RT-Thread内核的Tensorflow Lite嵌入式推理框架Tensorflow Lite Micro软件包. 通过本软件包可以实现在嵌入式系统中实现基于Tensorflow Lite框架训练的深度学习模型的端测部署任务.
7+
本软件包是针对RT-Thread生态移植的Tensorflow Lite Micro嵌入式推理框架, 主要解决在资源, 功耗, 性能等受限环境下的嵌入式系统中, 基于Tensorflow Lite框架训练的深度学习模型的端测部署问题.
88

99
### 1.1 目录结构
1010

1111
| 名称 | 说明 |
1212
| ---- | :--- |
1313
| docs | 文档目录 |
14-
| examples | Tensorflow Lite Micro自带语音历程, 并给出一些说明 |
15-
| fixedpoint | Tensorflow Lite Micro库需要的定点量化库 |
16-
| flatbuffers | Tensorflow Lite Micro库需要的模型解释库flatbuffer |
17-
| ruy | Tensorflow Lite Micro库需要的矩阵加速库ruy |
18-
| tensorflow | Tensorflow Lite Micro主体库 |
14+
| examples | Tensorflow Lite Micro示例 |
15+
| fixedpoint | Google Fixedpoint定点量化库 |
16+
| flatbuffers | Google Flatbuffer模型解释库 |
17+
| ruy | Google Ruy矩阵计算加速库 |
18+
| tflite | Tensorflow Lite Micro推理框架 |
1919

2020
### 1.2 许可证
2121

@@ -41,7 +41,6 @@ RT-Thread online packages
4141

4242
在成功下载 Tensorflow Lite Micro package 之后:
4343

44-
- 将下载在`packages`文件下的`TensorflowLiteMicro_xxx`(其中`xxx`为软件包版本号)软件包文件夹名更改为`TensorflowLiteMicro`(即去除版本号, 以免影响编译)
4544
- 通过menuconfig进行功能配置, 其中在menuconfig中的配置选项为:
4645

4746
```
@@ -50,6 +49,7 @@ RT-Thread online packages
5049
[*] Tensorflow Lite Micro: a lightweight deep learning end-test inference framework for RT-Thread operating system.
5150
Version(latest) --->
5251
Select Offical Example(Enable Tensorflow Lite Micro aduio example) --->
52+
Select Tensorflow Lite Operations Type (Using Tensorflow Lite reference operations) --->
5353
```
5454

5555
其中, Select Offical Example中有两个选项:
@@ -59,7 +59,18 @@ RT-Thread online packages
5959
( ) No Tensorflow Lite Micro example
6060
```
6161

62-
其中audio example是执行官方携带的语音demo, No example则是不集成example文件, 只使用Tensorflow Lite Micro标准框架. **关于menucofing选项的注意事项请参照 4. 注意事项部分**
62+
注 : audio example是执行官方携带的语音示例, No example则是不集成example文件, 只使用Tensorflow Lite Micro标准框架.
63+
64+
- 如果选择了语音示例, 则需要从example文件夹下拷贝audio_main.cc文件到工程的Application目录中, 然后即可以编译, 烧录/下载查看效果了
65+
66+
其中, Select Tensorflow Lite Operations Type中有两个选项:
67+
68+
```
69+
(X) Using Tensorflow Lite reference operations
70+
( ) Using Tensorflow Lite CMSIS NN operations
71+
```
72+
73+
注 : reference operation是应用TFLMicro的通用算子(算子与平台隔离,可移植性好), CMSIS NN operations是应用针对ARM平台进行特定优化的算子(主要针对Cortex M4内核以上的平台, 对于特定平台有特定加速). **有关注意事项请参照第四部分!!**
6374

6475
- Tensorflow Lite Micro整个框架功能较为复杂, API较多, 请先参考[introduction.md](introduction.md), 然后通过[user-guide.md](user-guide.md)来学习基本的部署流程, 在此基础之上再考虑自定义开发的问题.
6576

@@ -68,10 +79,10 @@ RT-Thread online packages
6879

6980
## 4、注意事项
7081

71-
- 如果在menuconfig中选择了audio example选项时, 软件包自带了main函数, 用户需要手动删除除了`packages/TensorflowLiteMicro/example/audio_main.cc`以外的所有main函数
72-
- 如果选择的是No example时, 系统没有main函数, 用户可以根据自身需要设计main函数来调用Tensorflow Lite Micro框架
73-
- **本软件包在编译之后大约会占用480KB Flash空间, 92KB RAM空间**, 所以不推荐硬件资源不多的MCU系统使用本软件包
74-
- 本软件包在运行时会占用16KB RAM空间, 同时自带的语音识别案例在运行时总共占用22KB内存, **需要通过menuconfig来修改主函数栈的大小以及内存管理算法 !**
82+
- 目前CMSIS NN算子还处在测试阶段, 可能存在问题.
83+
- 目前的CMSIS NN算子优化主要针对ARM Cortex M4以上的内核进行计算优化, 所以不推荐M4以下的MCU应用本选项.
84+
- 以集成语音demo的Tensorflow Lite Micro框架为例, **本软件包在编译之后大约会占用690KB Flash空间, 28K RAM空间** (平台数据 : 树莓派4 Cortex A72内核 64位, gcc-arm-8.3交叉工具链), 所以暂时不推荐硬件资源过于紧凑的MCU使用本软件包.(未来会针对资源紧凑型MCU进行定制优化)
85+
- 本软件包在运行时会占用16KB RAM空间, 同时自带的语音识别案例在运行时总共占用22KB内存, **请注意通过menuconfig来修改主函数栈的大小以及内存管理算法 !**
7586
- 本软件包目前只在树莓派4平台上实现成功运行, 其他平台还有待测试. 欢迎大家在其他平台上移植软件包并提出issue. 树莓派4移植仓库链接: https://github.com/QingChuanWS/raspi4-tfliteMicro
7687

7788
## 5、联系方式 & 感谢

examples/SConscript

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/audio_main.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,18 @@ limitations under the License.
1616
#include <rtthread.h>
1717
#include <rtdevice.h>
1818
#include <board.h>
19-
#include "packages/TensorflowLiteMicro/tensorflow/lite/micro/examples/micro_speech/main_functions.h"
19+
#include "tflite/micro/examples/micro_speech/main_functions.h"
2020

2121
// This is the default main used on systems that have the standard C entry
2222
// point. Other devices (for example FreeRTOS or ESP32) that have different
2323
// requirements for entry code (like an app_main function) should specialize
2424
// this main.cc file in a target-specific subfolder.
25-
int main(int argc, char** argv) {
25+
int main(int argc, char* argv[]) {
2626
setup();
2727
rt_kprintf("model load successfully!!\n");
2828
while (true) {
2929
loop();
3030
}
31+
3132
return 0;
3233
}

flatbuffers/SConscript

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ from building import *
22

33
cwd = GetCurrentDir()
44
src = Glob('*.c') + Glob('*.cc')
5-
CPPPATH = [cwd, str(Dir('#'))]
5+
CPPPATH = [cwd]
66

7-
group = DefineGroup('Flatbuffers', src, depend = ['PKG_USING_TENSORFLOWLITEMICRO'], CPPPATH = CPPPATH)
7+
group = DefineGroup('flatbuffers', src, depend = ['PKG_USING_TENSORFLOWLITEMICRO'], CPPPATH = CPPPATH)
88

99
Return('group')

flatbuffers/base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
#include <functional>
5454
#endif
5555

56-
#include "packages/TensorflowLiteMicro/flatbuffers/stl_emulation.h"
56+
#include "stl_emulation.h"
5757

5858
#if defined(__ICCARM__)
5959
#include <intrinsics.h>

flatbuffers/code_generators.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <map>
2121
#include <sstream>
2222

23-
#include "packages/TensorflowLiteMicro/flatbuffers/idl.h"
23+
#include "idl.h"
2424

2525
namespace flatbuffers {
2626

flatbuffers/flatbuffers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef FLATBUFFERS_H_
1818
#define FLATBUFFERS_H_
1919

20-
#include "packages/TensorflowLiteMicro/flatbuffers/base.h"
20+
#include "base.h"
2121

2222
#if defined(FLATBUFFERS_NAN_DEFAULTS)
2323
# include <cmath>

flatbuffers/flatc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
#include <limits>
2222
#include <string>
2323

24-
#include "packages/TensorflowLiteMicro/flatbuffers/flatbuffers.h"
25-
#include "packages/TensorflowLiteMicro/flatbuffers/idl.h"
26-
#include "packages/TensorflowLiteMicro/flatbuffers/util.h"
24+
#include "flatbuffers.h"
25+
#include "idl.h"
26+
#include "util.h"
2727

2828
namespace flatbuffers {
2929

flatbuffers/flatc_pch.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2017 Google Inc. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef FLATBUFFERS_FLATC_PCH_H_
18+
#define FLATBUFFERS_FLATC_PCH_H_
19+
20+
// stl
21+
#include <cmath>
22+
#include <sstream>
23+
#include <cassert>
24+
#include <unordered_set>
25+
#include <unordered_map>
26+
#include <iostream>
27+
#include <functional>
28+
#include <set>
29+
#include <iterator>
30+
#include <tuple>
31+
32+
// flatbuffers
33+
#include "pch.h"
34+
#include "code_generators.h"
35+
#include "flatbuffers.h"
36+
#include "flexbuffers.h"
37+
#include "idl.h"
38+
39+
#endif // FLATBUFFERS_FLATC_PCH_H_

flatbuffers/flexbuffers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
#include <map>
2121
// Used to select STL variant.
22-
#include "packages/TensorflowLiteMicro/flatbuffers/base.h"
22+
#include "base.h"
2323
// We use the basic binary writing functions from the regular FlatBuffers.
24-
#include "packages/TensorflowLiteMicro/flatbuffers/util.h"
24+
#include "util.h"
2525

2626
#ifdef _MSC_VER
2727
# include <intrin.h>

flatbuffers/hash.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <cstdint>
2121
#include <cstring>
2222

23-
#include "packages/TensorflowLiteMicro/flatbuffers/flatbuffers.h"
23+
#include "flatbuffers.h"
2424

2525
namespace flatbuffers {
2626

flatbuffers/idl.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
#include <memory>
2222
#include <stack>
2323

24-
#include "packages/TensorflowLiteMicro/flatbuffers/base.h"
25-
#include "packages/TensorflowLiteMicro/flatbuffers/flatbuffers.h"
26-
#include "packages/TensorflowLiteMicro/flatbuffers/flexbuffers.h"
27-
#include "packages/TensorflowLiteMicro/flatbuffers/hash.h"
28-
#include "packages/TensorflowLiteMicro/flatbuffers/reflection.h"
24+
#include "base.h"
25+
#include "flatbuffers.h"
26+
#include "flexbuffers.h"
27+
#include "hash.h"
28+
#include "reflection.h"
2929

3030
#if !defined(FLATBUFFERS_CPP98_STL)
3131
# include <functional>

flatbuffers/minireflect.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
#ifndef FLATBUFFERS_MINIREFLECT_H_
1818
#define FLATBUFFERS_MINIREFLECT_H_
1919

20-
#include "packages/TensorflowLiteMicro/flatbuffers/flatbuffers.h"
21-
#include "packages/TensorflowLiteMicro/flatbuffers/util.h"
20+
#include "flatbuffers.h"
21+
#include "util.h"
2222

2323
namespace flatbuffers {
2424

flatbuffers/pch.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2017 Google Inc. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef FLATBUFFERS_PCH_H_
18+
#define FLATBUFFERS_PCH_H_
19+
20+
// stl
21+
#include <cstdint>
22+
#include <cstring>
23+
#include <algorithm>
24+
#include <list>
25+
#include <string>
26+
#include <utility>
27+
#include <iomanip>
28+
#include <map>
29+
#include <memory>
30+
#include <limits>
31+
#include <stack>
32+
#include <vector>
33+
#include <type_traits>
34+
35+
// flatbuffers
36+
#include "util.h"
37+
38+
#endif // FLATBUFFERS_PCH_H_

flatbuffers/reflection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
// Should normally not be a problem since it can be generated by the
2323
// previous version of flatc whenever this code needs to change.
2424
// See reflection/generate_code.sh
25-
#include "packages/TensorflowLiteMicro/flatbuffers/reflection_generated.h"
25+
#include "reflection_generated.h"
2626

2727
// Helper functionality for reflection.
2828

flatbuffers/reflection_generated.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#ifndef FLATBUFFERS_GENERATED_REFLECTION_REFLECTION_H_
55
#define FLATBUFFERS_GENERATED_REFLECTION_REFLECTION_H_
66

7-
#include "packages/TensorflowLiteMicro/flatbuffers/flatbuffers.h"
7+
#include "flatbuffers.h"
88

99
namespace reflection {
1010

flatbuffers/registry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#ifndef FLATBUFFERS_REGISTRY_H_
1818
#define FLATBUFFERS_REGISTRY_H_
1919

20-
#include "packages/TensorflowLiteMicro/flatbuffers/idl.h"
20+
#include "idl.h"
2121

2222
namespace flatbuffers {
2323

flatbuffers/util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#include <errno.h>
2121

22-
#include "packages/TensorflowLiteMicro/flatbuffers/base.h"
22+
#include "base.h"
2323

2424
#ifndef FLATBUFFERS_PREFER_PRINTF
2525
# include <sstream>

ruy/profiler/SConscript

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ from building import *
22

33
cwd = GetCurrentDir()
44
src = Glob('*.c') + Glob('*.cc')
5-
CPPPATH = [cwd, str(Dir('#'))]
5+
CPPPATH = [cwd]
66

7-
group = DefineGroup('ruy', src, depend = ['BSP_USING_TFLITE'], CPPPATH = CPPPATH)
7+
group = DefineGroup('ruy', src, depend = ['PKG_USING_TENSORFLOWLITEMICRO'], CPPPATH = CPPPATH)
88

99
Return('group')

ruy/profiler/instrumentation.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
1515

16-
#include "packages/TensorflowLiteMicro/ruy/profiler/instrumentation.h"
16+
#include "instrumentation.h"
1717

1818
#ifdef RUY_PROFILER
1919

tensorflow/lite/SConscript

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)