I believe the “handroll”-ed convolution is defined here: https://github.com/pytorch/pytorch/blob/master/aten/src/THNN/generic/SpatialConvolutionMM.c 124
The NN module implementations are here: https://github.com/pytorch/pytorch/tree/master/aten/src 84
The GPU version is in THCUNN and the CPU version in THNN