Ethos-u ML Evaluation kit examples

Clone this repo:
  1. 8b0455c MLECO-3545: Minor updates to CMSIS-packs by Kshitij Sisodia · 23 hours ago main
  2. 4548850 MLECO-3518: Separates CMakePrests by Maksims Svecovs · 6 days ago
  3. 9d329f4 MLECO-3518: Move to CMake 3.23.3 by Maksims Svecovs · 6 days ago
  4. db7c518 MLECO-3545: Removing PIDX and updating pack URL by Kshitij Sisodia · 7 days ago
  5. 8d03c19 MLECO-3546: Adding CMSIS pack with pidx file by Kshitij Sisodia · 8 days ago

Arm® ML embedded evaluation kit

This repository is for building and deploying Machine Learning (ML) applications targeted for Arm® Cortex®-M and Arm® Ethos™-U NPU. To run evaluations using this software, we suggest using:

Overview of the evaluation kit

The purpose of this evaluation kit is to allow users to develop software and test the performance of the Arm® Ethos-U NPU and Arm® Cortex-M CPUs for ML workloads. The Ethos-U NPU is a new class of machine learning (ML) processor, specifically designed to accelerate ML computation in constrained embedded and IoT devices. The product is optimized to execute mathematical operations efficiently that are commonly used in ML algorithms, such as convolutions or activation functions.

ML use cases

The evaluation kit adds value by providing ready to use ML applications for the embedded stack. As a result, you can experiment with the already developed software use cases and create your own applications for Cortex-M CPU and Ethos-U NPU. The example application at your disposal and the utilized models are listed in the table below.

ML applicationDescriptionNeural Network Model
Image classificationRecognize the presence of objects in a given imageMobilenet V2
Keyword spotting(KWS)Recognize the presence of a key word in a recordingMicroNet
Automated Speech Recognition(ASR)Transcribe words in a recordingWav2Letter
KWS and ASRUtilise Cortex-M and Ethos-U to transcribe words in a recording after a keyword was spottedMicroNet Wav2Letter
Anomaly DetectionDetecting abnormal behavior based on a sound recording of a machineMicroNet
Visual Wake WordRecognize if person is present in a given imageMicroNet
Noise ReductionRemove noise from audio while keeping speech intactRNNoise
Generic inference runnerCode block allowing you to develop your own use case for Ethos-U NPUYour custom model
Object detectionDetects and draws face bounding box in a given imageYolo Fastest

The above use cases implement end-to-end ML flow including data pre-processing and post-processing. They will allow you to investigate embedded software stack, evaluate performance of the networks running on Cortex-M55 CPU and Ethos-U NPU by displaying different performance metrics such as inference cycle count estimation and results of the network execution.

Software and hardware overview

The evaluation kit primarily supports Arm® Corstone™-300 and Arm® Corstone™-310 reference packages as its primary targets. Arm® Corstone™-300 design implementation is publicly available on an Arm MPS3 FPGA board, or as a Fixed Virtual Platform of the MPS3 development board.

The Ethos-U NPU software stack is described here.

All ML use cases, albeit illustrating a different application, have common code such as initializing the Hardware Abstraction Layer (HAL). The application common code can be run on native host machine (x86_64 or aarch64) or Arm Cortex-M architecture thanks to the HAL. For the ML application-specific part, Google® TensorFlow™ Lite for Microcontrollers inference engine is used to schedule the neural networks models executions. TensorFlow Lite for Microcontrollers is integrated with the Ethos-U NPU driver and delegates execution of certain operators to the NPU or, if the neural network model operators are not supported on NPU, to the CPU. If the operator is supported, CMSIS-NN is used to optimise CPU workload execution with int8 data type. Else, TensorFlow™ Lite for Microcontrollers' reference kernels are used as a final fall-back. Common ML application functions will help you to focus on implementing logic of your custom ML use case: you can modify only the use case code and leave all other components unchanged. Supplied build system will discover new ML application code and automatically include it into compilation flow.

A high level overview of the different components in the software, and the platforms supported out-of-the-box, is shown in the diagram below.

APIs

For a more detailed description of the build graph with all major components, see Building.

Reusable software

There are source files in the repository that form the core of the Machine Leaning flow for all the use cases. These are exposed as APIs that the examples can use and even be combined to form chained use cases. The API sources are designed to be portable across platforms and provide functionality for preprocessing of data, running an inference, and postprocessing of results. These allow a common flow for all use cases with minor differences in how each of these blocks are instantiated.

As an independent CMake project, these APIs can be used by or integrated into other projects easily. We also produce CMSIS Packs with these sources, so they could be used in all tools/IDEs (for example, Arm® Development Studio and Keil® µVision®) that support the use of CMSIS Packs.

Getting started

To run an ML application on the Cortex-M and Ethos-U NPU, please, follow these steps:

  1. Set up your environment by installing the required prerequisites.

NOTE: A Docker image built from the Dockerfile provided will have all the required packages installed.

  1. Generate an optimized neural network model for Ethos-U with a Vela compiler by following instructions here.
  2. Configure the build system.
  3. Compile the project with a make command.
  4. If using a FVP, launch the desired application on the FVP. If using the FPGA option, load the image on the FPGA and launch the application.

To get familiar with these steps, you can follow the quick start guide.

Note: The default flow assumes Arm® Ethos™-U55 NPU usage, configured to use 128 Multiply-Accumulate units and is sharing SRAM with the Arm® Cortex®-M55.

Ml embedded evaluation kit supports:

Ethos™-U NPUDefault MACs/ccOther MACs/cc supportedDefault Memory ModeOther Memory Modes supported
Ethos™-U5512832, 64, 256Shared_SramSram_Only
Ethos™-U65256512Dedicated_SramShared_Sram

For more information see Building.

For more details see full documentation:

Contribution guidelines

Contributions are only accepted under the following conditions:

  • The contribution have certified origin and give us your permission. To manage this process we use Developer Certificate of Origin (DCO) V1.1. To indicate that contributors agree to the terms of the DCO, it's necessary "sign off" the contribution by adding a line with name and e-mail address to every git commit message:

    Signed-off-by: John Doe <john.doe@example.org>
    

    This can be done automatically by adding the -s option to your git commit command. You must use your real name, no pseudonyms or anonymous contributions are accepted.

  • You give permission according to the Apache License 2.0.

    In each source file, include the following copyright notice:

    /*
    * Copyright (c) <years additions were made to project> <your name>, Arm Limited. All rights reserved.
    * SPDX-License-Identifier: Apache-2.0
    *
    * Licensed under the Apache License, Version 2.0 (the "License");
    * you may not use this file except in compliance with the License.
    * You may obtain a copy of the License at
    *
    *     http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
    

Coding standards and guidelines

This repository follows a set of guidelines, best practices, programming styles and conventions, see:

Code Reviews

Contributions must go through code review. Code reviews are performed through the mlplatform.org Gerrit server. Contributors need to sign up to this Gerrit server with their GitHub account credentials. In order to be merged a patch needs to:

  • get a "+1 Verified" from the pre-commit job.
  • get a "+2 Code-review" from a reviewer, it means the patch has the final approval.

Testing

Prior to submitting a patch for review please make sure that all build variants works and unit tests pass. Contributions go through testing at the continuous integration system. All builds, tests and checks must pass before a contribution gets merged to the main branch.

Communication

Please, if you want to start public discussion, raise any issues or questions related to this repository, use https://discuss.mlplatform.org/c/ml-embedded-evaluation-kit forum.

Licenses

The ML Embedded applications samples are provided under the Apache 2.0 license, see License Apache 2.0.

Application input data sample files are provided under their original license:

LicenceProvenience
Automatic Speech Recognition SamplesCreative Commons Attribution 4.0 International Public Licensehttp://www.openslr.org/12/
Image Classification SamplesCreative Commons Attribution 1.0https://www.pexels.com
Keyword Spotting SamplesCreative Commons Attribution 4.0 International Public Licensehttp://download.tensorflow.org/data/speech_commands_v0.02.tar.gz
Keyword Spotting and Automatic Speech Recognition SamplesCreative Commons Attribution 4.0 International Public Licensehttp://download.tensorflow.org/data/speech_commands_v0.02.tar.gz
Visual Wake Word SamplesCreative Commons Attribution 1.0https://www.pexels.com
Noise Reduction SamplesCreative Commons Attribution 4.0 International Public Licensehttps://datashare.ed.ac.uk/handle/10283/2791/
Object Detection SamplesCreative Commons Attribution 1.0https://www.pexels.com