Where exactly is the padding implemented within a Conv2d layer?

I am trying to understand the padding procedure in the Conv2d Layer (torch.nn.modules.conv). As far as I know the padding is done implicitly, which means the zeros aren’t actually added to the input but only assumed for convolution. I am trying to find the exact place where this is implemeted.

Obviously the conv2d() function (torch.nn.functional) is called in the forward pass of a Conv2d Layer, but in the 4.0 PyTorch version the only thing I can find is the respective docstring. Furthermore, I don’t fully understand how this C Wrapper works and which function is called at that point. I already had a look at some of the C files (such as aten.src.ATen.native.Convolution, aten.src.THNN.generic.SpatialConvolutionMM, aten.src.THNN.generic.SpatialConvolutionMap), but couldn’t find the function where the implicit padding is implemented.

I would be glad if someone could point me in the right direction!

Thank you all in advance!

Maria

implicit padding is implemented in three code paths:

Out of curiosity, what are you planning to do?