This article will describe how to use the HiFi modules found on certain NXP microcontrollers as an optional method for inferencing a model.
There are several ways of running a TFLite neural network model on NXP microcontrollers:
This article will cover options #2 and #4 which make use of the HiFi DSP module. Running a model on the HiFi4 (option #2) will be much faster than running a model just on the CM33/M7 (option #1).
However using the NPU (options #3 and #4) will be significantly faster than only using the DSP due to the hardware optimizations that an NPU provides for neural network calculations. The exact performance gains will be model specific, and also depend on the layer(s) that may not have been converted to use the NPU as NeutronGraph nodes. The accuracy should remain the very similar regardless of method being used. Any type of TFLite neural network model can be ran on the HiFi1/HiFi4 as those DSP modules are just being used accelerate the neural network math that the model uses.
CIFAR10 on i.MX RT700 using default MCUXpresso SDK projects:
*HiFi1 runs at 32MHz
Software requirements:
Go to the Cadence i.MX RT700 or Cadence i.MX RT685 pages to download the following software.
If using a HiFi4 example then download the HiFi4 license and DSP configuration files. Likewise, if using a HiFi1, then will need the HiFi1 license and DSP configuration files. Also you will need to download the Windows or Linux version of these files depending on which host OS you are using on your PC.
Finally add the following global system variables which should be set based on the location that Xtensa Explorer was installed (assuming RT700 with HiFi4):
MCUXpresso SDK HiFi ML Examples:
There are several HiFi related examples in MCUXpresso SDK for i.MX RT700:
When using the HiFi eIQ projects provided in MCUXpresso SDK, ensure that the SDK is:
Extending Memory Area in HiFi4 Examples for Larger Models:
Open:
\boards\mimxrt700evk\eiq_examples\tflm_cifar10_hifi4_neutron\linker\hifi4\min-rt\ldscripts\elf32xtensa.x
And make modifications below to extend the memory used for models.
dsp_core_seg : org = 20200000, len = 0x200000
dsp_core_ncache_seg : org = 0x20400000, len = 0x180000
_memmap_mem_dsp_core_start = 0x20200000;
_memmap_mem_dsp_core_end = 0x20580000;
_memmap_seg_dsp_core_start = 0x20200000;
_memmap_seg_dsp_core_max = 0x20580000;
Ensure that the stack heap is at 0x2058_0000:
PROVIDE(__stack = 0x20580000);
_heap_sentry = 0x20580000;
Now larger models will compile successfully in Xtensa.
Then after copying in the compiled HiFi4 binary files into the MCUXpresso IDE project, modify source/dsp_config.h file to update the DSP_SRAM_ADDRESS:
Then clean and build the project.
HiFi Lab:
See the attached lab document for more details on using the HiFi DSP modules to inference models.