mit-han-lab / tinyengine

[NeurIPS 2020] MCUNet: Tiny Deep Learning on IoT Devices; [NeurIPS 2021] MCUNetV2: Memory-Efficient Patch-based Inference for Tiny Deep Learning; [NeurIPS 2022] MCUNetV3: On-Device Training Under 256KB Memory
https://mcunet.mit.edu
MIT License
757 stars 127 forks source link

A potential bug with respect to padding in convolve_s8_kernel3_inputch3_stride2_pad1_fpreq #95

Closed huangzhengxiang closed 9 months ago

huangzhengxiang commented 9 months ago

Thanks for your great work!

When reading through your code and learn from it, we encountered several confusing lines which may be a potential bug.

In file convolve_s8_kernel3_inputch3_stride2_pad1_fpreq.c, the function 'convolve_s8_kernel3_inputch3_stride2_pad1_fpreq', padding is handled by checking if it's the first column and row, such as if (base_idx_y != -1) { if (base_idx_x != -1) { //load all for now and unroll all However, this means that the last column and row are not padded properly.

The following picture illustrates what we mean. The yellow blocks illustrate the items that you padded, while the red ones illustrate the items that you potentially missed. image

Is this a bug?

We're looking forward to your response! Thank you in advance!

huangzhengxiang commented 9 months ago

Thank you!

I have just read your code again. When input shape is even, this function is correct, because only the first column and row are needed to be padded.

image