Compare commits

...

2 Commits

Author SHA1 Message Date
iabdalkader
e25ee48874 ports/alif: Handle pending events during inference.
Ensures pending events get serviced more often.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-09-22 14:09:24 +02:00
iabdalkader
5698c45130 lib/stai: Poll events during inference.
Ensures pending events get serviced more often.

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-09-22 08:28:28 +02:00
2 changed files with 24 additions and 3 deletions

View File

@ -234,6 +234,7 @@ int ml_backend_init_model(py_ml_model_obj_t *model) {
}
int ml_backend_run_inference(py_ml_model_obj_t *model) {
LL_ATON_RT_RetValues_t ll_aton_rt_ret;
ml_backend_state_t *state = (ml_backend_state_t *) model->state;
// Flush input buffers.
@ -242,7 +243,25 @@ int ml_backend_run_inference(py_ml_model_obj_t *model) {
SCB_CleanDCache_by_Addr(LL_Buffer_addr_start(buf), LL_Buffer_len(buf));
}
LL_ATON_RT_Main(&state->nn_inst);
LL_ATON_RT_RuntimeInit();
LL_ATON_RT_Init_Network(&state->nn_inst);
do {
// Execute first/next runtime step
ll_aton_rt_ret = LL_ATON_RT_RunEpochBlock(&state->nn_inst);
// Handle pending events (TinyUSB, OMV Protocol etc..)
mp_handle_pending(false);
// Wait for the next event
if (ll_aton_rt_ret == LL_ATON_RT_WFE) {
LL_ATON_OSAL_WFE();
}
} while (ll_aton_rt_ret != LL_ATON_RT_DONE);
LL_ATON_RT_DeInit_Network(&state->nn_inst);
LL_ATON_RT_RuntimeDeInit();
return 0;
}

View File

@ -35,6 +35,8 @@
#include CMSIS_MCU_H
#include "py/mphal.h"
#include "py/runtime.h"
#include "alif_hal.h"
#include "omv_boardconfig.h"
#include "ethosu_driver.h"
@ -150,11 +152,11 @@ uint64_t ethosu_address_remap(uint64_t address, int index) {
}
void ethosu_inference_begin(struct ethosu_driver *drv, void *user_arg) {
mp_handle_pending(false);
}
void ethosu_inference_end(struct ethosu_driver *drv, void *user_arg) {
mp_handle_pending(false);
}
void ETHOSU_IRQ_HANDLER(void) {