cancel
Showing results for 
Search instead for 
Did you mean: 

Error with generated Edge AI code

oliv_ch
Associate

The examples/code snippets found in the ST Edge AI Core Technology Documentation (ST Edge AI Core Technology 2.2.0) show a variety of functions/macros used that don't seem to get generated via STM32CubeMX on my end.

For reference, I generated the code for CMake, with version 10.2.0 of X-Cube-AI and 6.13.0 of STM32CubeMX.

A couple examples from the legacy client -> new edge ai embedded client migration guide:

  • #include "network_inputs.h" - No such file <model_name>_inputs.h seems to get generated via CubeMX.
  • STAI_NETWORK_CONTEXT_DECLARE - this macro is undeclared in the generated code.
  • stai_network_init() - I get an implicit declaration of function warning for this one (cannot find this declared/defined anywhere in the generated code).
  • STAI_NETWORK_ACTIVATIONS_NUM - also undeclared in generated code.

 

Is this specific to the code generated for CMake? Are there perhaps other header files I should be looking to include aside form the ones noted in the examples?

 

EDIT: Confirmed that these issues are also still present with the code generated for STM32CubeIDE, so issues seem to be platform agnostic.

6 REPLIES 6
Maxime_MARCHETTO
Community manager
Community manager

Hello @oliv_ch,

This post has been escalated to the ST Online Support Team for additional assistance. We'll contact you directly.

Best regards,
Maxime


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
kahuna
Associate II

From what I understand, X-CUBE-AI and ST Edge AI are two completely separate things and have nothing in common.

X-CUBE-AI is a package for CubeMX to create the app templates/validation apps for a given model (e.g. TFLite). Here, the code is generated purely in C. ST Edge AI, on the other hand, is a more recent software tool to generate APIs and static libraries of a given model to be included in your custom project. It has a completely different client API (incl. header names) and - from what I found so far - does not generate pure C code. Instead, the actual calculation is "hidden" inside of a static library to be included in your custom project. The generated code merely defines the API, buffers, and model dimensions of the static library. This is somewhat contrary to the ST Edge AI marketing, which suggests that the model is converted to *.c/*.h files.

That being said, I am still figuring out ST's AI tool landscape which is pretty confusing ...

Hello @kahuna,

 

The ST Edge AI Core is, as its name indicate, the core component of AI within ST.

 

X Cube AI is a GUI inside CubeMX that calls the ST Edge AI Core CLI. In X Cube AI, the "Analyze" call the analyze in the core CLI (if you look at the terminal while doing the analyze, you will clearly see it calling the ST Edge AI Core). In the same way, the "Validate on desktop" and "Validate on Target" are simply calling the Validate command in the core.  And finally, when generating the core, it calls the generate function of the CLI.

 

As you pointed out, X Cube AI is able to generate template code thanks to the cubeMX environment.

The Core generate the code for the model (as you described in your comment), CubeMX generate the code around it to make a use of it.

 

There is no question like : Should I use the Core or X cube AI, it is, do I just want the model => core, or do I also want some config and template code => X Cube AI (and Core).

 

The same idea is applied to the ST Developer Cloud, it is another tool, online this time, that work thanks to the ST Edge AI Core.

 

The ST Model Zoo Services also uses the Core when using the Deployment operation mode.

 

In one word, every code related to neural network within ST was obtained with the Core (STM32,MP2,STellar etc).


NanoEdge AI Studio is the only exception (to my knowledge). It does not work with the ST Edge AI Core.

 

I hope it is clearer.

 

Have a good day,

Julian


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hello @Julian E. ,

thanks for the clarification.

I was always under the impression that X-CUBE-AI generates pure C code but after your comment I checked again and now I found the sub-directory which contains the ST Edge AI part including the static library.

I'm wondering why the tool generates a static library instead of *.c/*.h files. Is this a design choice or have I just not found how to do it? Pure C code would be better in certain scenarios because it allows for verification, debugging, static code analysis, etc.

Best regards,

kahuna

 

Hello @kahuna,

 

It is a design choice. Probably not to share the source code. I don't know the reasoning behind it.

But you did not miss anything, it is indeed like that.

 

Have a good day,

Julian


In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.
michaeljyti
Associate II

This is platform-agnostic, and the current CubeMX/X-Cube-AI release doesn’t fully generate STAI APIs yet. What you see generated is still the legacy style.