2.2.0
How-to integrate generated code


ST Edge AI Core

How-to integrate generated code


for ISPU target, based on ST Edge AI Core Technology 2.2.0



r1.2

Template

The template for integrating the code generated by ST Edge AI Core on ISPU can be obtained from ST’s GitHub repository for ISPU: https://github.com/STMicroelectronics/st-mems-ispu.

The ispu folder of the template may be copied by itself (no dependencies other than the CLI toolchain or IDE environment that must be installed) and used as a starting project to integrate any model converted using ST Edge AI Core.

For how to setup the development environment for ISPU, refer to the GitHub repository linked above.

Model implementation generation

The template project is structured so that ST Edge AI Core can automatically populate it with the necessary files in the right places. In order to achieve that, run the following command:

stedgeai generate --target ispu --no-workspace --no-report -m <nn_model_file> --output <ispu_folder>

where nn_model_file is the file containing the model of the neural network to convert and ispu_folder is a copy of the ispu folder of the template. Of course, additional options can be added to the generate command above as needed.

Alternatively, MEMS Studio’s ISPU Model Converter can be used to generate the network code, specifying ispu_folder as the output directory. ST Edge AI Developer Cloud can also be used to generate and download the converted code.

Integration of the model

Once the code has been generated, the project will build, but it will output a number of warnings. Their purpose is to alert to the fact that, in order to complete the integration of the neural network model in the ISPU code, a few modifications specific to the model and the use case are necessary in ispu/src/main.c:

As always, ispu/conf.txt, ispu/meta.txt, and ispu/shub.txt should also be modified as required. For more information on these files, please refer to the regular (not specific for ST Edge AI) ISPU template.

Note: the template supports one single model generated with the default name “network”. Integrating multiple networks or one network with a different name would require modifying the code to a greater extent than what was shown here.

For more information on the code generated by ST Edge AI Core and how to use it, please refer to the other articles in this documentation.