1.. zephyr:code-sample:: tflite-ethosu
2   :name: TensorFlow Lite for Microcontrollers on Arm Ethos-U
3
4   Run an inference using an optimized TFLite model on Arm Ethos-U NPU.
5
6Overview
7********
8
9A sample application that demonstrates how to run an inference using the TFLM
10framework and the Arm Ethos-U NPU.
11
12The sample application runs a model that has been downloaded from the
13`Arm model zoo <https://github.com/ARM-software/ML-zoo>`_. This model has then
14been optimized using the
15`Vela compiler <https://git.mlplatform.org/ml/ethos-u/ethos-u-vela.git>`_.
16
17Vela takes a tflite file as input and produces another tflite file as output,
18where the operators supported by Ethos-U have been replaced by an Ethos-U custom
19operator. In an ideal case the complete network would be replaced by a single
20Ethos-U custom operator.
21
22Building and running
23********************
24
25Add the tflite-micro module to your West manifest and pull it:
26
27.. code-block:: console
28
29    west config manifest.project-filter -- +tflite-micro
30    west update
31
32This application can be built and run on any Arm Ethos-U capable platform, for
33example Corstone(TM)-300. A reference implementation of Corstone-300 can be
34downloaded either as a FPGA bitfile for the
35`MPS3 FPGA prototyping board <https://developer.arm.com/tools-and-software/development-boards/fpga-prototyping-boards/mps3>`_,
36or as a
37`Fixed Virtual Platform <https://developer.arm.com/tools-and-software/open-source-software/arm-platforms-software/arm-ecosystem-fvps>`_
38that can be emulated on a host machine.
39
40Assuming that the Corstone-300 FVP has been downloaded, installed and added to
41the ``PATH`` variable, then building and testing can be done with following
42commands.
43
44.. code-block:: bash
45
46    $ west build -b mps3/corstone300/an547 zephyr/samples/modules/tflite-micro/tflm_ethosu
47    $ FVP_Corstone_SSE-300_Ethos-U55 build/zephyr/zephyr.elf
48