Understanding the Internal Working of AI2D Module from nncase_runtime

Viewed 79

Hey CanMV Community,

I have been exploring the AI2D module from the nncase_runtime library in the K230 CanMV SDK, referring to the API manual:
🔗https://developer.canaan-creative.com/k230_canmv/en/main/api/aidemo/Ai2d_Module_API_Manual.html

I want to gain a deeper understanding of how AI2D works internally. Since it appears to be integrated into the firmware, I am unable to access its implementation directly(Correct me if i am Wrong and provide me how can I check where is this nncase_runtime lib present?). Specifically, I have the following questions:

AI2D Functionality & Math Behind It
How does ai2d.padding work internally?

What mathematical operations or transformations are applied?

Is there a way to inspect the logic behind AI2D functions?

Execution Order in ai2d.builder.run
If I use ai2d.crop, then ai2d.resize, then ai2d.pad, will these be executed exactly in this order?

Or does ai2d.builder.run optimize or modify the execution sequence internally?

How can I verify the actual order of execution?

I need to understand this behavior to align AI2D's processing with my specific use case. My goal is to comprehend what exactly happens in the backend and how AI2D manages these operations.

2 Answers

Hello, the AI2D module is a hardware-implemented preprocessing module that supports 'resize/crop/padding/affine/shift' methods. This module has already been integrated into the firmware. For the API details, please refer to 'https://developer.canaan-creative.com/k230_canmv/zh/main/zh/api/nncase/K230_CanMV_nncase_runtime_API%E6%89%8B%E5%86%8C.html#nncase-runtime-ai2d'. We have noticed that the English documentation is incomplete, and we will fix it as soon as possible.

Thank you for you response,

However, would it be possible to access the source code for AI2D and nncase? I’d like to understand the internal implementation of AI2D, particularly how it handles resizing, padding, and cropping. This would help me better understand how AI2D processes these operations for face detection and recognition on this hardware.

The documentation explains how to use the module, but it does not cover its internal workings. If you could share the source code, it would be greatly helpful.

Looking forward to your insights! Thanks again.