Skip to main content
JTedot
Associate III
September 10, 2021
Solved

ai_instrumodel_data_weights_get() causes "has no member" error in AI_BUFFER_OBJ_INIT struct (instrumodel is the model name)

  • September 10, 2021
  • 1 reply
  • 1197 views

Calling the ai_instrumodel_data_weights_get() function has problems with the AI_BUFFER_OBJ_INIT struct in "ai_platform.h". I'm following this guide exactly step by step: https://www.digikey.com/en/maker/projects/tinyml-getting-started-with-stm32-x-cube-ai/f94e1c8bfc1e4b6291d0f672d780d2c0

What I don't understand is the fact that an initialization tells me that it has no members. What is this based on to claim this error? It's defined right there, i should be able to define whatever I want. That's like saying "int i = 0; is undefined". No, it's defined right here. To reproduce, copy the code in the link and run it with Cube IDE 1.7.0 and X Cube AI 7.0.0

This topic has been closed for replies.
Best answer by jean-michel.d

Hello, JTedot,

I suppose that the error is generated when you try to initialize the ai_network_params structure before to call the ai_instrumodel_init() function. With 7.0 (should have been also the case with the previous versions, but not correctly documented) is to use the macro AI_NETWORK_PARAMS_INIT() instead to set directly the fields. With the v7 the definition of ai_network_params is not exactly the same.

 const ai_network_params params = AI_NETWORK_PARAMS_INIT(
 AI_NETWORK_DATA_WEIGHTS(ai_instrumodel_data_weights_get()),
 AI_NETWORK_DATA_ACTIVATIONS(activations)
 );

br,

jm

1 reply

jean-michel.dBest answer
ST Employee
September 10, 2021

Hello, JTedot,

I suppose that the error is generated when you try to initialize the ai_network_params structure before to call the ai_instrumodel_init() function. With 7.0 (should have been also the case with the previous versions, but not correctly documented) is to use the macro AI_NETWORK_PARAMS_INIT() instead to set directly the fields. With the v7 the definition of ai_network_params is not exactly the same.

 const ai_network_params params = AI_NETWORK_PARAMS_INIT(
 AI_NETWORK_DATA_WEIGHTS(ai_instrumodel_data_weights_get()),
 AI_NETWORK_DATA_ACTIVATIONS(activations)
 );

br,

jm

JTedot
JTedotAuthor
Associate III
September 10, 2021

thank you very much, this works with the newest version. May I link to your answer on other forums?