Hi, thank you very much! I was able to match the result from scipy.signal.convolve2d(img, mask, mode='same', boundary='symm') with the following Pytorch code:
imgs = torch.rand(2048, 1, 12, 12, dtype=torch.float32, device='cuda')
# F.conv2d does a cross correlation so be sure to flip the mask to do a convolution
mask = torch.flip(torch.tensor([[-1, 1],[-1, 1]], dtype=torch.float32), [0, 1]).expand(1, 1, 2, 2).to('cuda')
pad = torch.nn.ReplicationPad2d((1, 0, 1, 0))
return F.conv2d(pad(imgs), mask)

Again, thank you very much!