This document contains the general information on building and running TensorFlow Lite Micro for targets based on the Synopsys ARC VPX and EM/HS Processors.
The Synopsys DesignWare ARC MetaWare Development Toolkit (MWDT) is required to build and run Tensorflow Lite Micro applications for all ARC VPX and EM/HS targets.
To license MWDT, please see further details here
To request an evaluation version of MWDT, please use the Synopsys Eval Portal and follow the link for the MetaWare Development Toolkit (Important: Do not confuse this with MetaWare EV Development Toolkit or MetaWare Lite options also available on this page)
Run the downloaded installer and follow the instructions to set up the toolchain on your platform.
TensorFlow Lite for Microcontrollers builds are divided into two phases: Application Project Generation and Application Project Building/Running. The former phase requires *nix environment while the latter does not.
For basic project generation targeting ARC EM Software Development Platform, MetaWare is NOT required for the Project Generation Phase. However, it is required in case the following: - For project generation for custom (not EM SDP) targets - To build microlib target library with all required TFLM objects for external use
Please consider the above when choosing whether to install Windows or Linux or both versions of MWDT
This section describes how to deploy on an ARC EM SDP board
To use the EM SDP, you need the following hardware and software:
More information on the platform, including ordering information, can be found here.
See Install the Synopsys DesignWare ARC MetaWare Development Toolkit section for instructions on toolchain installation.
If you wish to use the MetaWare Debugger to debug your code, you need to also install the Digilent Adept 2 software, which includes the necessary drivers for connecting to the targets. This is available from official Digilent site. You should install the “System” component, and Runtime. Utilities and SDK are NOT required.
Digilent installation is NOT required if you plan to deploy to EM SDP via the SD card instead of using the debugger.
A 'make' tool is required for both phases of deploying Tensorflow Lite Micro applications on ARC EM SDP:
For the first phase you need an environment and make tool compatible with Tensorflow Lite for Micro build system. At the moment of this writing, this requires make >=3.82 and a *nix-like environment which supports shell and native commands for file manipulations. MWDT toolkit is not required for this phase.
For the second phase, requirements are less strict. The gmake version delivered with MetaWare Development Toolkit is sufficient. There are no shell and *nix command dependencies, so Windows can be used
The Debug UART port of the EM SDP is used to print application output. The USB connection provides both the debug channel and RS232 transport. You can use any terminal emulation program (like PuTTY) to view UART output from the EM SDP.
If you want to self-boot your application (start it independently from a debugger connection), you also need a microSD card with a minimum size of 512 MB and a way to write to the card from your development host. Note that the card must be formatted as FAT32 with default cluster size (but less than 32 Kbytes)
| Switch # | Switch position |
|---|---|
| 1 | Low (0) |
| 2 | Low (0) |
| 3 | High (1) |
| 4 | Low (0) |
U-Boot <Versioning info> CPU: ARC EM11D v5.0 at 40 MHz Subsys:ARC Data Fusion IP Subsystem Model: snps,emsdp Board: ARC EM Software Development Platform v1.0 …
If you want to use TensorFlow Lite Micro framework in your own application, you need to generate TFLM as a static library. Next command can be used to generate TFLM library for ARC EM SDP:
make -f tensorflow/lite/micro/tools/make/Makefile clean make -f tensorflow/lite/micro/tools/make/Makefile TARGET=arc_emsdp \ TARGET_ARCH=arc \ OPTIMIZED_KERNEL_DIR=arc_mli \ microlite
Generated library libtensorflow-microlite.a can be found in gen/{target}/lib.
Example applications can be found on ARC examples repository.
This section describes how to build TFLM using embARC MLI Library 2.0.
The EmbARC MLI Library 2.0 can be used to build TFLM library and run applications (especially for VPX processors).
Because of difference in weights layout, TFLM models must be pre-adapted using a Model Adaptation Tool. For native TFLM examples (person detection, micro speech) Model Adaptation Tool is applied automatically when MLI 2.0 is used, so there is no need to run it maually.
To use the embARC MLI Library 2.0 in all cases (including native examples), you will also need extra dependencies for the Model Adaptation Tool. Please check the Model Adaptation Tool section for more information.
To build TFLM using the embARC MLI Library 2.0, add the following tag to the command:
ARC_TAGS=mli20_experimental
Also, some of configurations may require custom BUILD_LIB. Please, check MLI Library 2.0 documentation for more details. Following option can be added:
BUILD_LIB_DIR=<path_to_buildlib>
Example of command to build TFLM lib for VPX5:
make -f tensorflow/lite/micro/tools/make/Makefile \ TARGET=arc_custom \ TCF=<path_to_tcf_file> \ BUILD_LIB_DIR=vpx5_integer_full \ ARC_TAGS=mli20_experimental microlite
Models in TFLM format need to be pre-adapted before being used with MLI 2.0 due to differences in weights' tensor layout in some kernels. Adaptation is done automatically during TFLM project generation, but requires TensorFlow to be installed.
To use the Model Adaptation Tool, you need the following tools in addition to common requirments:
If you want to use your own model, exported from TensorFlow in .tflite or .cc format, you will need to adapt it manually using the Model Adaptation Tool from the current folder, using the following command:
python adaptation_tool.py <path_to_input_model_file> \ <path_to_adapted_model_file>
This section describes how to deploy on a Custom ARC VPX or EM/HS platform defined only by a TCF (Tool onfiguration File, created at CPU configuration time) and optional LCF (Linker Command File). In this case, the real hardware is unknown, and applications can be run only in the nSIM simulator included with the MetaWare toolkit.
VPX support is presented as an experimental feature of supporting embARC MLI Library version 2.0 and model adaptation. Read more about embARC MLI Library 2.0 support in the related section.
To use a custom ARC EM/HS/VPX platform, you need the following :
See Install the Synopsys DesignWare ARC MetaWare Development Toolkit section for instructions on toolchain installation. See MetaWare Development Toolkit and Make Tool sections for instructions on toolchain installation and comments about make versions.
If you want to use TensorFlow Lite Micro framework in your own application, you need to generate TFLM as a static library. Next command can be used to generate TFLM library:
make -f tensorflow/lite/micro/tools/make/Makefile clean make -f tensorflow/lite/micro/tools/make/Makefile \ TARGET_ARCH=arc \ TARGET=arc_custom \ OPTIMIZED_KERNEL_DIR=arc_mli \ TCF_FILE=<path_to_tcf_file> \ LCF_FILE=<path_to_lcf_file> \ microlite
For MLI Library 2.0 (experimental feature):
make -f tensorflow/lite/micro/tools/make/Makefile clean make -f tensorflow/lite/micro/tools/make/Makefile \ TARGET_ARCH=arc \ TARGET=arc_custom \ OPTIMIZED_KERNEL_DIR=arc_mli \ ARC_TAGS=mli20_experimental \ BUILD_LIB_DIR=<path_to_buildlib> \ TCF_FILE=<path_to_tcf_file> \ microlite
Generated library libtensorflow-microlite.a can be found in gen/{target}/lib.
Example applications can be found on ARC examples repository.
TensorFlow's code is covered by the Apache2 License included in the repository, and third-party dependencies are covered by their respective licenses, in the third_party folder of this package.