Understand adapative averge pooling 2d

Hi, I’m trying to understand adapative average pooling 2d does.

For example, for the following code:
input = torch.randn(1,1,4,4)
m = torch.nn.AdaptiveAvgPool2d((5,7))
output = m(input)

it executes fine but what confuses me is why it works even the input HxW is less than kernel size. Does it automatically padding 0 to the size of the kernel ?

Thanks a lot,

I don’t think it’s padding anything, but instead iterates the output pixels (as seen here) and calculates the average of the corresponding input positions (as seen here).