2388055_en-US

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

2388055_en-US

2388055_en-US

eIQ Neutron NPU Support in Zephyr

Zephyr now supports the eIQ Neutron NPU on MCX N and i.MX RT700. This article will describe how to get Zephyr and use the eIQ Neutron NPU libraries and examples. 

Some previous experience with eIQ Neutron NPU enablement is assumed, so ensure you're familiar with the eIQ Neutron SDK, converting models for eIQ Neutron NPU, and basic ML concepts by going through the MCX N or i.MX RT700  NPU bare-metal lab guides for VS Code before continuing on below. 

Install Software

  1. Run the MCUXpresso Installer tool and install three key components:
      1. Zephyr Developer
      2. Arm GNU Toolchain
      3. Zephyr SDK
      4. LinkServer
      5. anthony_huereca_0-1782845821454.png
  2. Install LinkServer and add LinkServer to the PATH
  3. Install VS Code and MCUxpresso VS Code plugin

Download Zephyr

  1. Open VSCode
  2. Go to the MCUXpresso for VSCode plugin and click on Import Repository
  3. Go to the Remote tab and select the Zephyr repository. Choose it a directory name and location to download the repository to, and then click on Import.
  4. anthony_huereca_1-1782845403033.png
  5. It will take approximately 30 minutes to download the repository. Near the end of the download there will be several prompts in the terminal asking to accept licenses. Type “y” to accept and hit enter. There will be about 10 of these prompts at the end.
  6. Open the MCUXpresso Venv Terminal which has a Python virtual environment with all the paths preconfigured that were installed by MCUXpresso Installer.
  7. anthony_huereca_2-1782845420922.png
  8. In the terminal that pops up, type “1” to select the default environment.
  9. Then navigate to the directory you downloaded Zephyr into
  10. Run the following commands to get TensorFlow:

    west config manifest.project-filter -- +tflite-micro

    west update

  11. Go into the zephyr subdirectory folder

    cd zephyr

  12. Now need to explicitly download the Pull Request (PR) that enables eIQ Neutron. This eventually won’t be necessary when Zephyr 4.5 is released in October, but until then will need to type the following In the command prompt to get it:

    git remote -v

    git remote add upstream https://github.com/zephyrproject-rtos/zephyr.git

    git remote -v

     

    git stash

    git fetch upstream pull/108834/head:pr-108834

    git checkout pr-108834


  13. After this command you should see there’s now a folder at \ \zephyr\samples\boards\nxp\tflm_neutron with example source code.

Compile and Run a Zephyr eIQ Neutron NPU example

  1. Compile the project with west: 
    • For MCX N:

west build -p auto -b frdm_mcxn947/mcxn947/cpu0 samples/boards/nxp/tflm_neutron

 

  • For RT700:

west build -p auto -b mimxrt700_evk/mimxrt798s/cm33_cpu0 samples/boards/nxp/tflm_neutron

  1. Open TeraTerm or other serial terminal program, and connect to the virtual COM port that board enumerated as when you plugged in the USB cable. Use 115200 baud, 1 stop bit, no parity.
  2. Flash the resulting code with west flash
  3. The serial terminal should show the following:
  4. anthony_huereca_3-1782845441830.png
  5. Can debug with west debug


 Run your own NPU accelerated ML model in Zephyr

Make sure you've gone through the MCX N or i.MX RT700  hands-on labs so you're familiar with the enablement. The same steps for converting a model with the Neutron Converter tool inside eIQ Neutron SDK, updating the eIQ Neutron libraries, modfiying the operator list, and adding a new model are relevant when using Zephyr, but the file locations will be Zephyr specific. Also note that the header file generated by the Neutron Converter tool will need to be updated to match the header of the model.hpp file. 

Also note that the README.rst file in the Zephyr Neutron example mentions using eIQ Toolkit but that information is outdated and been superseded by eIQ Neutron SDK. 

  • eIQ Neutron example is at \zephyr\samples\boards\nxp\tflm_neutron
  • Neutron libraries are at \modules\hal\nxp\zephyr\blobs\neutron\
  • Model data is at \zephyr\samples\boards\nxp\tflm_neutron\src\models\mcxn\model.hpp
  • Labels file is at \zephyr\samples\boards\nxp\tflm_neutron\src\labels.h
  • kTensorArenaSize variable is set in \zephyr\samples\boards\nxp\tflm_neutron\src\main_functions.cpp (line 40) and is set to 60KB by default
  • OpResolver is set in \zephyr\samples\boards\nxp\tflm_neutron\src\main_functions.cpp (line 65)
  • The model is selected in \zephyr\samples\boards\nxp\tflm_neutron\src\main_functions.cpp (line 11)

Additional References:

Hands-On Training
タグ(1)
評価なし
バージョン履歴
最終更新日:
昨日
更新者: