you can make use of torch.nn.functional.conv2d() 47.
import torch.nn.functional as F
kernel = torch.Tensor([[[[1,2,3], [0,4,0], [0,5,0]]]])
data = torch.randn(1,1,10,10)
output = F.conv2d(data, kernel)