tree: 48e4f459a01dc96144081de98696ac55a2116440
  1. include/
  2. src/
  3. .gitignore
  4. arm-none-eabi-gcc.cmake
  5. convert_image.py
  6. convert_labels.py
  7. corstone300.ld
  8. Makefile
  9. README.md
  10. requirements.txt
  11. run_demo.sh
apps/microtvm/ethosu/README.md

Running TVM on bare metal Arm(R) Cortex(R)-M55 CPU, Ethos(TM)-U55 NPU and CMSIS-NN

This folder contains an example of how to use TVM to run a model on bare metal Cortex(R)-M55 CPU, Ethos(TM)-U55 NPU and CMSIS-NN.

Prerequisites

If the demo is run in the ci_cpu Docker container provided with TVM, then the following software will already be installed.

If the demo is not run in the ci_cpu Docker container, then you will need the following:

You will also need TVM which can either be:

  • Built from source (see Install from Source)
    • When building from source, the following need to be set in config.cmake:
      • set(USE_ETHOSU ON)
      • set(USE_CMSISNN ON)
      • set(USE_MICRO ON)
      • set(USE_LLVM ON)
  • Installed from TLCPack(see TLCPack)

You will need to update your PATH environment variable to include the path to cmake 3.19.5 and the FVP. For example if you've installed these in /opt/arm , then you would do the following:

export PATH=/opt/arm/FVP_Corstone_SSE-300/models/Linux64_GCC-6.4:/opt/arm/cmake/bin:$PATH

Running the demo application

Type the following command to run the bare metal demo application (src/demo_bare_metal.c):

./run_demo.sh

To run the demo using FreeRTOS task scheduling and queues (src/demo_freertos.c), specify the path to FreeRTOS using --freertos_path, for example:

./run_demo.sh --freertos_path /opt/freertos/FreeRTOSv202112.00/

If the Ethos(TM)-U driver and/or CMSIS have not been installed in /opt/arm/ethosu then the locations for these can be specified as arguments to run_demo.sh, for example:

./run_demo.sh --ethosu_driver_path /home/tvm-user/ethosu/core_driver --cmsis_path /home/tvm-user/cmsis \
--ethosu_platform_path /home/tvm-user/ethosu/core_platform

This will:

  • Download a quantized (int8) mobilenet v2 model
  • Use tvmc to compile the model for Cortex(R)-M55 CPU, Ethos(TM)-U55 NPU and CMSIS-NN
  • Download an image of a penguin to run the model on
  • Create a C header file inputs.c containing the image data as a C array
  • Create a C header file outputs.c containing a C array where the output of inference will be stored
  • Build the Ethos(TM)-U55 core driver
  • Build the demo application
  • Run the demo application on a Fixed Virtual Platform (FVP) based on Arm(R) Corstone(TM)-300 software
  • The application will display what the image has been classified as e.g. “The image has been classified as ‘king penguin’”

Using your own image

The create_image.py script takes a single argument on the command line which is the path of the image to be converted into an array of bytes for consumption by the model.

The demo can be modified to use an image of your choice by changing the following lines in run_demo.sh

curl -sS https://upload.wikimedia.org/wikipedia/commons/1/18/Falkland_Islands_Penguins_29.jpg -o penguin.jpg
python3 ./convert_image.py ./build/penguin.jpg