2025-06-10 6:01 AM
Hello,
I'm doing my machelor thesis, and I found a very interesting phenomenon. I deployed a Yolov8n from model zoo inside the N6 Nucleo Board NPU(by modifying the template project from the DK board and Input from the UART with CRC code to make sure the picture is send correctly.) the inference seems to be right. However, when I input the same data (same picture with same crc code), the output can be different!!???? Is this phenomenon right? or its because I messed up sth. when I change the project???????
Also even if I deploy this Yolov8n inside CPU without NPU, the outcome is still different when giving the same input. (the reference seems also working correctly.) Is this also correct??? any explanation or documentation for this?
(the mAP can have a 20% different when giving 10 same pictures)
Also when using a mobilenet v2 the same phenomenon is also found both in CPU and NPU,( top 5 class is same ,but the confidence can have a difference up to about 20 %)
please give me some ideas whether this is right or wrong, when its wrong, what should I do to fix this? when right, can you give me some documentations about this?
Thanks a lot in advance.
Solved! Go to Solution.
2025-06-17 7:24 AM - edited 2025-06-17 7:33 AM
Hello,
Thanks for the update.
Could you tell us a bit more about how/when/what you do to do cache maintenance ?
Most likely, if you do an inference using NPU, what you would need to do is something like:
software epoch controller may rely on DCACHE for acceleration
This is not true, the epoch controller does not have access to CPU-D$: data is fetched by DMAs that are independent from the CPU (stream engines of the NPU).
Could you try to clean & invalidate, but not invalidate & clean and tell us if this fixes your issues ?
2025-06-17 5:58 AM
Hello @Einstein_rookie_version,
Though very interesting, this behaviour is not expected, as you would assume :)
Seemingly random behaviours like this are often caused by issues when using the caches present in the system i.e. bad cache maintenance.
Could you check the behaviour of your code when you disable the MCU data cache ? If this works better, then you may want to dig into that and ensure that the MCU cache is properly "flushed" (cleaned) before handling inference to the NPU. (otherwise the image may be in the the mcu data cache, but not written into memory... and the npu does not access the mcu datacache, but the physical memory)
This, however, does not fully explain the issue if you have the same issue when using only MCU inference... How did you do the inference "using MCU only ?"
Sorry, this may sound silly but could you double check that your program does not overwrite the weights of the network between inferences (i.e. a buffer overflow when doing uart transmissions for example), or that the memory used for storing activations is not messed up with during inference ?
Should those two possible tracks be unfruitful, could you please share "minimal" working examples (but with a buggy inference) of your two projects ? (CPU only / with NPU)
Thanks !
2025-06-17 6:13 AM
Thanks a lot for the reply, I also tried to explore more these days. I can narrow down to the D cache as the cause of this phenomenon.
The reason for the CPU model inference, is because of
2025-06-17 7:24 AM - edited 2025-06-17 7:33 AM
Hello,
Thanks for the update.
Could you tell us a bit more about how/when/what you do to do cache maintenance ?
Most likely, if you do an inference using NPU, what you would need to do is something like:
software epoch controller may rely on DCACHE for acceleration
This is not true, the epoch controller does not have access to CPU-D$: data is fetched by DMAs that are independent from the CPU (stream engines of the NPU).
Could you try to clean & invalidate, but not invalidate & clean and tell us if this fixes your issues ?
2025-06-17 8:05 AM
Thanks a lot for the help, this is really really helpful. By only cleaning before the reference and then invalidate after the reference, the randomness is gone. Thanks a lof again for the excellent solution and explanation!!!!!!!