This repository contains for the TensorFlow Lite for Microcontrollers port supporting ADI microcontrollers and digital signal processors.
This project is covered under the Apache License 2.0.
The TFLite Micro Library for SHARC-FX is built upon the TensorFlow Lite Micro framework developed by Google. You can read more about this framework here. The product consists of the TFLite Micro library for SHARC-FX, sample applications and associated documents. This repository contains code from TFLM master branch as of July 2023. This port was created following the new platform support instructions.
Our optimized implementation of this framework is designed to specifically run on ADI’s SHARC-FX line of processors. Currently, this contains support for the following devices.
This codebase was tested with CrossCore Embedded Studio >3.0.0 on a Windows 10 host machine. For information about the CrossCore Embedded Studio tool chain refer to www.analog.com/cces. For more information on the latest ADI processors, technical support and any other additional information, please visit our website at http://www.analog.com/processors.
You will need the following hardware:
- Analog Devices ADSP-SC835W-SOM - This is a small board containing the SC835 processor (SHARC-FX + M33) and JTAG.
- Analog Devices EV-SOMCRR-EZKIT - This adapter board provides all of the peripherals for the denoiser application.
- ICE-1000 or ICE-2000 - An in-circuit emulator used to debug and download the application to the processor.
- USB cable with USB A and Micro USB-B connectors (for ICE connection)
- USB cable with Type A connectors (for carrier board connection)
- USB cable with Type C connectors (for SOM board connection)
- 12 V AC adaptor to Power EV-SOMCRR-EZKIT board
You have the option to power the board via USB or from an AC-DC power supply. The diagrams below show the connections for these two power options. Please take that the JP1 jumper setting changes depending on the power source used.
Figure 1. System block diagram using USB power supply
Figure 2. System block diagram using 9V-20V DC power supply
To build the project, you will need to download and install the following software:
-
CrossCore Embedded Studio
- You will need CrossCore Embedded Studio, version 3.0.0 and above, available from analog.com/cces. CrossCore Embedded Studio includes a 90-day full-featured trial license. Alternatively, the SC835W SOM provides a license that is not time-limited but restricted to use with the ADSP-SC835 and ICE-1000.
-
Make (> 4.3.0)
- You will need this if you want to run the headless build workflow.
The examples folder includes the SHARC-FX port for the following applications:
- DTLN (Dual-signal Transformation LSTM Network) denoiser
- CNN genre identification
- DS-CNN keyword spotting
Building the example application is a two-stage process. First, you will need to build the static library archive (libTFLM.a
). The generated library archive is then linked and built together with the example application project to create the executable file. To illustrate:
We will discuss two options to build and run the examples:
Follow the steps below for a graphical-based approach
First, open the project on CCES:
- Open the project by choosing the File > Import in CrossCore Embedded Studio.
- In the Import window, select Existing Projects into Workspace and click Next.
- In the next window, click Browse and provide the path to the examples directory as the Select root directory.
- Select any of the projects and click Finish.
- You will see the opened project in the IDE’s Project Explorer.
Next, build the libTFLM.a
file:
- Right click on the opened project and click on Build Configurations > Set Active. You may choose either the Debug or Release for the build configuration.
- For the selected configuration:
- Click Project > Clean. Ensure that only the required project is selected in the Clean window. If desired, build the project immediately after cleaning. Configure to start a build immediately only for the selected project and click OK. This is an optional, but recommended step.
- If the previous step has not already built the project, then click Project-> Build Project or press F7.
- The binary (*.dxe) will be created in the
Debug
orRelease
folder located in the workspace, depending on the selected configuration. The workspace folder is specified at the top of this section.
At this point, you should have a libTFLM.a
library archive located inside the Debug
or Release
folder.
Instructions to build and run the examples are found in their respective READMEs.
We have also included utilities for automated model conversion and flashing. These are available in the utils directory.
We also provide a CLI-based build workflow that is equivalent to the IDE-based workflow in the CCES ecosystem. The headless interface supports building the libTFLM.a
library archive.
To build the library archive for TFLM with the optimized kernels, run make on the top-level directory:
make
By default, the build script uses /c/analog/cces
as the search path for the SHARC-FX toolchains and the default target is for the ADSP-SC835.
RELEASE
is the default configuration but you may also select to DEBUG
configuration mode.
To configure these, run
make SHARCFX_ROOT=</path/to/cces> DEVICE=<DEVICE_NAME> CONFIG=<CONFIG_MODE>
The script will output a ./build/libTFLM.a
library which can be linked to other projects using the -lTFLM
flag.
Build objects are stored in the ./build
directory. To remove these, run
make clean
The headless interface also allows building and flashing an example project. To build an example application:
cd examples/<example_project>/<example_realtime|fileio>
make
To flash to the board with a debugger, run
make flash
The default debugger is ICE-1000. To configure this with other debugger like the ICE-2000, run
make flash DEBUGGER=2000
Please raise a GitHub Issue for support.