未验证 提交 dc5da70d 编写于 作者: A Artem Tsvetkov 提交者: GitHub

Updated micro speech example to work with embARC MLI Library 2.0 (#234)

上级 58f4c2e1
......@@ -18,7 +18,7 @@ kilobytes of Flash.
## Table of contents
- [Deploy to ARC EM SDP](#deploy-to-arc-em-sdp)
- [Running on ARC](#running-on-ARC)
- [Deploy to Arduino](#deploy-to-arduino)
- [Deploy to ESP32](#deploy-to-esp32)
- [Deploy to SparkFun Edge](#deploy-to-sparkfun-edge)
......@@ -30,8 +30,9 @@ kilobytes of Flash.
- [Run the tests on a development machine](#run-the-tests-on-a-development-machine)
- [Train your own model](#train-your-own-model)
## Deploy to ARC EM SDP
## Running on ARC
### **Deploy on ARC EMSDP**
The following instructions will help you to build and deploy this example to
[ARC EM SDP](https://www.synopsys.com/dw/ipdir.php?ds=arc-em-software-development-platform)
board. General information and instructions on using the board with TensorFlow
......@@ -78,7 +79,7 @@ reduce total size of application. It can be omitted.
For more detailed information on building and running examples see the
appropriate sections of general descriptions of the
[ARC EM SDP usage with TFLM](/tensorflow/lite/micro/tools/make/targets/arc/README.md#ARC-EM-Software-Development-Platform-ARC-EM-SDP).
[ARC EM SDP usage with TensorFlow Lite Micro (TFLM)](/tensorflow/lite/micro/tools/make/targets/arc/README.md#ARC-EM-Software-Development-Platform-ARC-EM-SDP).
In the directory with generated project you can also find a
*README_ARC_EMSDP.md* file with instructions and options on building and
running. Here we only briefly mention main steps which are typically enough to
......@@ -88,10 +89,10 @@ get it started.
[connect the board](/tensorflow/lite/micro/tools/make/targets/arc/README.md#connect-the-board)
and open an serial connection.
2. Go to the generated example project director
2. Go to the generated example project directory.
```
cd tensorflow/lite/micro/tools/make/gen/arc_emsdp_arc/prj/micro_speech_mock/make
cd tensorflow/lite/micro/tools/make/gen/arc_emsdp_arc_default/prj/micro_speech_mock/make
```
3. Build the example using
......@@ -128,6 +129,66 @@ get it started.
In both cases (step 5 and 6) you will see the application output in the serial
terminal.
### **Deploy on ARC VPX processor**
The [embARC MLI Library 2.0](https://github.com/foss-for-synopsys-dwc-arc-processors/embarc_mli/tree/Release_2.0_EA) enables TFLM library and examples to be used with the ARC VPX processor. This is currently an experimental feature. General information and instructions on using embARC MLI Library 2.0 with TFLM can be found in the common [ARC targets description](/tensorflow/lite/micro/tools/make/targets/arc/README.md).
### Initial Setup
Follow the instructions in the [Custom ARC EM/HS/VPX Platform](/tensorflow/lite/micro/tools/make/targets/arc/README.md#Custom-ARC-EMHSVPX-Platform) section to get and install all the required tools for working with the ARC VPX Processor.
### Generate Example Project
The example project for ARC VPX platform can be generated with the following
command:
```
make -f tensorflow/lite/micro/tools/make/Makefile \
TARGET=arc_custom\
ARC_TAGS=mli20_experimental \
BUILD_LIB_DIR=<path_to_buildlib> \
TCF_FILE=<path_to_tcf_file> \
LCF_FILE=<path_to_lcf_file> \
OPTIMIZED_KERNEL_DIR=arc_mli \
generate_micro_speech_mock_make_project
```
TCF file for VPX Processor can be generated using tcfgen tool which is part of [MetaWare Development Toolkit](#MetaWare-Development-Toolkit). \
The following command can be used to generate TCF file to run applications on VPX Processor using nSIM Simulator:
```
tcfgen -o vpx5_integer_full.tcf -tcf=vpx5_integer_full -iccm_size=0x80000 -dccm_size=0x40000
```
VPX Processor configuration may require a custom run-time library specified using the BUILD_LIB_DIR option. Please, check MLI Library 2.0 [documentation](https://github.com/foss-for-synopsys-dwc-arc-processors/embarc_mli/tree/Release_2.0_EA#build-configuration-options) for more details.
### Build and Run Example
For more detailed information on building and running examples see the
appropriate sections of general descriptions of the
[Custom ARC EM/HS/VPX Platform](/tensorflow/lite/micro/tools/make/targets/arc/README.md#Custom-ARC-EMHSVPX-Platform).
In the directory with generated project you can also find a
*README_ARC.md* file with instructions and options on building and
running. Here we only briefly mention main steps which are typically enough to
get started.
1. Go to the generated example project directory.
```
cd tensorflow/lite/micro/tools/make/gen/vpx5_integer_full_mli20_arc_default/prj/micro_speech_mock/make
```
2. Build the example using
```
make app
```
3. To run application from the MetaWare Debugger installed in your environment:
* From the console, type `make run`.
* To stop the execution type `Ctrl+C` in the console several times.
In both cases (step 5 and 6) you will see the application output in the serial
terminal.
## Deploy to Arduino
The following instructions will help you build and deploy this example to
......
ifeq ($(TARGET_ARCH), arc)
ifneq ($(filter $(ARC_TAGS), mli20_experimental), )
# Patch of arc make project to adjust it specifically for micro speech example.
# In particular:
# - Adapt the model to be used with MLI by transposing weights tensors
MICRO_SPEECH_HDRS += \
micro_speech_patch.txt
MICRO_SPEECH_TEST_HDRS += \
micro_speech_patch.txt
MICRO_SPEECH_MOCK_HDRS += \
micro_speech_patch.txt
MODEL_PATH = /tensorflow/lite/micro/examples/micro_speech/micro_features
# Apply changes in generated project files.
# See related comment echoed (@echo <comment>) after each change
# to get understanding on it's purpose.
%/micro_speech_patch.txt: %$(MODEL_PATH)/model.cc
@python tensorflow/lite/micro/tools/make/targets/arc/adaptation_tool.py $<
@echo Makefile: Adapted the model to be used with MLI >> $@
endif
endif
......@@ -17,11 +17,12 @@ ifeq ($(TARGET), arc_emsdp)
micro_speech_patch.txt
ARC_MLI_BACKEND_PATH = /tensorflow/lite/micro/kernels/arc_mli
MODEL_PATH = /tensorflow/lite/micro/examples/micro_speech/micro_features
# Apply changes in generated project files.
# See related comment echoed (@echo <comment>) after each change
# to get understanding on it's purpose.
%/micro_speech_patch.txt: %/emsdp.lcf %/Makefile %$(ARC_MLI_BACKEND_PATH)/depthwise_conv.cc
%/micro_speech_patch.txt: %/emsdp.lcf %/Makefile %$(ARC_MLI_BACKEND_PATH)/depthwise_conv.cc %$(MODEL_PATH)/model.cc
@cp tensorflow/lite/micro/examples/micro_speech/arc_emsdp/emsdp.lcf $<
@echo emsdp.lcf: Example specific memory map > $@
......@@ -35,6 +36,10 @@ ifeq ($(TARGET), arc_emsdp)
@echo Makefile: set scratch buffers size to 0 >> $@
@echo Makefile: No Reference fallback for MLI supported functions >> $@
ifneq ($(filter $(ARC_TAGS), mli20_experimental), )
@python tensorflow/lite/micro/tools/make/targets/arc/adaptation_tool.py $(word 4, $^)
@echo Makefile: Called python script >> $@
endif
ifneq ($(filter $(ARC_TAGS), reduce_codesize),)
# In case 'reduce_codesize' tag is present, we replace common MLI functions with
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册