cancel
Showing results for 
Search instead for 
Did you mean: 

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

JTedot
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
jean-michel.d
ST Employee

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

View solution in original post

2 REPLIES 2
jean-michel.d
ST Employee

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

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