2021-08-09 01:43 AM
I have trained a neural network model and trying to implement it using STM32L476RG Nucleo board. I have generated an application template and the input to the neural network is 32 X 32 X 1.
I'm trying to understand below parameters in network_audio_ai.h.
#define AI_NETWORK_AUDIO_AI_IN_1_HEIGHT (32)
#define AI_NETWORK_AUDIO_AI_IN_1_WIDTH (32)
#define AI_NETWORK_AUDIO_AI_IN_1_CHANNEL (1)
#define AI_NETWORK_AUDIO_AI_IN_1_SIZE (32 * 32 * 1)
#define AI_NETWORK_AUDIO_AI_IN_1_SIZE_BYTES (AI_NETWORK_AUDIO_AI_IN_1_SIZE * 4)
The AI_NETWORK_AUDIO_IN_1_SIZE matched my trained model. My question is what is AI_NETWORK_AUDIO_AI_IN_SIZE_BYTES? Why do we need to multiply 4?
Are there any documents about this? Thank you very much!
Solved! Go to Solution.
2021-08-11 09:28 AM
Hi,
AI_NETWORK_AUDIO_AI_IN_1_SIZE indicates the total size of the input buffer in term of number of items/elements. AI_NETWORK_AUDIO_AI_IN_1_SIZE_BYTES indicates the associated size in bytes. I suppose in your case that the type of data for the input is float, this explains the 4 ( = sizeof(float)).
AI_NETWORK_AUDIO_AI_IN_1_SIZE_BYTES can be used to allocate or to define the input data buffer to store the input data.
If the buffer is allocated statically, you have two possibilities:
ai_float in_data[AI_NETWORK_AUDIO_AI_IN_1_SIZE]
// or
AI_ALIGNED(4) // to align the buffer on 4-byte boundary
ai_unit8 in_data[AI_NETWORK_AUDIO_AI_IN_1_SIZE_BYTES];
Arrangement/layout of the data/items inside the buffer is dependent of the shape but it follows the standard C-definition for the arrays. See "C-memory layouts" section in the embedded documentation ("Embedded Inference Client API" article.
(typical location of the doc in the X-CUBE-AI pack: C:\Users\<user_name>\STM32Cube\Repository\Packs\STMicroelectronics\X-CUBE-AI\7.0.0\Documentation\index.html).
br,
Jean-Michel
2021-08-09 06:51 PM
Further to my previous question, what's the actual size of the input data to the model? Is it AI_NETWORK_AUDIO_AI_IN_1_SIZE or AI_NETWORK_AUDIO_AI_IN_1_SIZE_BYTES?
2021-08-10 10:37 PM
Anyone that could help me on this?
2021-08-11 09:28 AM
Hi,
AI_NETWORK_AUDIO_AI_IN_1_SIZE indicates the total size of the input buffer in term of number of items/elements. AI_NETWORK_AUDIO_AI_IN_1_SIZE_BYTES indicates the associated size in bytes. I suppose in your case that the type of data for the input is float, this explains the 4 ( = sizeof(float)).
AI_NETWORK_AUDIO_AI_IN_1_SIZE_BYTES can be used to allocate or to define the input data buffer to store the input data.
If the buffer is allocated statically, you have two possibilities:
ai_float in_data[AI_NETWORK_AUDIO_AI_IN_1_SIZE]
// or
AI_ALIGNED(4) // to align the buffer on 4-byte boundary
ai_unit8 in_data[AI_NETWORK_AUDIO_AI_IN_1_SIZE_BYTES];
Arrangement/layout of the data/items inside the buffer is dependent of the shape but it follows the standard C-definition for the arrays. See "C-memory layouts" section in the embedded documentation ("Embedded Inference Client API" article.
(typical location of the doc in the X-CUBE-AI pack: C:\Users\<user_name>\STM32Cube\Repository\Packs\STMicroelectronics\X-CUBE-AI\7.0.0\Documentation\index.html).
br,
Jean-Michel
2021-08-11 10:00 PM
Thank you very much. May I know what is the purpose of AI_ALIGNED(4)?