Announcements

Help us improve the Power & Sensing Selection Guide. Share feedback

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
songyi
Level 1
Level 1
First like received First like given First reply posted

Hello,

 

I am implementing a project that takes the audio data from the microphone of the cy8cproto-o62-4343w board and passes it to my Machine Learning model. I downloaded the PDM_PCM_Audio project in the ModusToolbox and modified it. However, we noticed the ML model takes longer time than we want to get an inference. Hence,  we want to run the project with optimization to speed to reduce the inference time.  I found the Makefile in the PDM_PCM_Audio project, as shown in the picture below.

  

songyi_0-1678715302995.png

 

 

songyi_1-1678715671213.png

 

I have modified this Makefile and made CFLAGS=-O3 and Ofast as well as changed the VFP_SELECT. However, the speed is the same compared to before the modification when I checked the event’s inference time. Do I miss anything? What are the right steps to do in order to change the optimization of the project? I am attaching the code that I used to calculate the inference time. 

 

 

 

 

uint32_t tick = 0;

void systick_isr(void)



{

    tick++;

}

/*timer set up*/

Cy_SysTick_Init(CY_SYSTICK_CLOCK_SOURCE_CLK_IMO,(8000000/1000)-1);

Cy_SysTick_SetCallback(0, systick_isr);        // point to SysTick ISR to increment the 1ms count





for (uint32_t index = 0; index < FRAME_SIZE ; index ++)

            {

                //volume += abs(audio_frame[index]);

             int16_t val_temp = audio_frame[index];

             val = ((float) val_temp) / 32767.0f;

             tick = 0;

             IMAI_enqueue(&val);

             if (IMAI_dequeue(out) == IMAI_RET_SUCCESS)

             {

             printf("Inference time: %lu \r\n",tick);

             if (out[2] >confidence){printf("Baby_cry: %f\r\n",out[2]);}



             }

            }


 

 

Thanks and Best Regards,

Songyi Ma

0 Likes
1 Solution
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

You need to set CONFIG to "Custom" to use the optimization flags set using CFLAGS. Set VFP_SELECT to "hardfp". All of these changes should be done to the top-level project makefile.

View solution in original post

3 Replies
songyi
Level 1
Level 1
First like received First like given First reply posted

I changed CY_TOOLCHAIN_OPTIMIZATION=-Ofast in [users folder]\mtb_shared\recipe-make-cat1a\release-v1.8.0\make\toolchains\GCC_ARM.mk, and speed increased.  However,  I am still not sure where I should define VFP_SELECT. 

DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

You need to set CONFIG to "Custom" to use the optimization flags set using CFLAGS. Set VFP_SELECT to "hardfp". All of these changes should be done to the top-level project makefile.

RodolfoGL
Employee
Employee
250 solutions authored 250 sign-ins 5 comments on KBA

Hi Songyi,

Are you using our Infineon Machine Learning solution? If yes, note that we pre-built the libraries and delivered as .a files. Any changes in the optimization will only affect your application code, such as feature extraction algorithms and any other logic involved in the application level.

There is also different options in terms of inferencing, such as choosing between TFLM and Infineon own engine. They would have different performance numbers depending on the model used.

0 Likes