Hello Axon
The Hello Axon sample demonstrates how to run neural model inference on the Axon NPU using the Axon NPU driver directly. Use this sample if you are working directly with the Axon NPU compiler.
Requirements
The sample supports the following development kits:
Hardware platforms |
PCA |
Board name |
Board target |
|---|---|---|---|
PCA10184 |
|
Overview
The regression model runs on the Axon NPU and supports both synchronous and asynchronous inference modes.
This regression model uses Zephyr’s TensorFlow Lite for Microcontrollers: Hello World sample.
The model’s task is to replicate the sine function in the range from 0 to 2π.
The TensorFlow Lite file describing this model is processed by the Axon NPU Compiler to convert it into a format accepted by the Axon NPU.
The compilation output is saved in src/generated/nrf_axon_model_hello_axon_.h.
Configuration
See Configuring and building for information about how to permanently or temporarily change the configuration.
Configuration options
The following sample-specific Kconfig options are used in this sample:
- CONFIG_ASYNC_INFERENCE
(bool) Run inference asynchronously
- CONFIG_AVOID_INPUT_DOUBLE_COPY
(bool) Avoid copying of input data twice in synchronous inference mode
This option removes unnecessary copying of input data between buffers, but it requires exclusive access to the Axon NPU interlayer buffer to preserve consistency.
Building and running
This sample can be found under samples/hello_axon in the Edge AI Add-on folder structure.
To build the sample, follow the instructions in Building an application for your preferred building environment. See also Programming for programming steps and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.
Testing
After programming the sample to your development kit, complete the following steps to test it:
Connect the kit to the computer using a USB cable. The kit is assigned a serial port. Serial ports are referred to as COM ports on Windows, /dev/ttyACM devices on Linux, and /dev/tty devices on macOS. To list Nordic Semiconductor devices connected to your computer together with their serial ports, open a terminal and run the
nrfutil device listcommand. Alternatively, check your operating system’s device manager or its equivalent.Connect to the kit with a terminal emulator (for example, the Serial Terminal app). See Testing and optimization for the required settings and steps.
Reset the development kit.
Observe the logging output.
Sample output
The following output is logged in the terminal:
I: Hello Axon sample I: Initializing Axon NPU I: Running asynchronous inference I: prediction: 0.051, ideal 0.072 I: prediction: 0.847, ideal 0.842 I: prediction: -0.491, ideal -0.500 ...
Dependencies
This sample uses the following Edge AI Add-on libraries:
It uses the following Zephyr libraries: