2025-08-15 10:36 PM
Hello everyone,
I’m currently deploying multiple models on STM32 using X-CUBE-AI (for example: first using an MLP for a coarse classification “Gas / Not Gas”, then a second model for detailed gas class identification). I’d like to ask about two main topics:
Both models have identical input dimensions, data type (float32), and layout (e.g. 1x60 vector).
I’d like to point both models’ ai_buffer.data to the same float in[60], then call ai_*_run sequentially (never in parallel).
Is this approach safe/supported in X-CUBE-AI? Could any model overwrite the input buffer during inference (theoretically it shouldn’t, but I’d like to confirm with ST/others)
When two (or more) models coexist on the same MCU:
A. Keep completely separate weights[] and activations[] (independent), each with its own create/init/run/destroy.
B. Is it possible/recommended to share the activation memory (only when models run sequentially)? If yes, is this officially supported and safe?
Regarding ai_mnetwork (multi-model manager) and accessing the models’ native I/O descriptors:
My understanding: I can use ai_mnetwork_get_private_handle() to obtain each sub-model’s private handle, then call ai_<model>_inputs_get() / ai_<model>_outputs_get() to retrieve the native ai_buffer arrays, avoiding manual shape/format filling.
Is this the officially recommended workflow? Or is it better practice to use the report structure and manually fill shapes and formats?
Is input buffer sharing safe and supported when models are executed sequentially?
For outputs with different formats (float, int, logits, one-hot), is it always recommended to rely on *_get_report() or *_outputs_get() instead of hardcoding?
Can activations be shared safely between models if they are strictly serialized? Any official examples or caveats?
Is using ai_mnetwork the recommended way to manage multiple models (vs. manually handling multiple sets of ai_buffer)?
Thanks a lot for any guidance, best practices, or references to official examples/docs!
2025-08-15 10:50 PM
And How to use the second model , It would be better if there is a example code