Do the small windows overlap? If so, you would have to think about a method to unite them (summing, mean, etc.).
If not, you could try the following:
channels = 1
h, w = 12, 12
image = torch.randn(1, channels, h, w)

kh, kw = 3, 3 # kernel size
dh, dw = 3, 3 # stride

patches = image.unfold(2, kh, dh).unfold(3, kw, dw)
patches = patches.contiguous().view(-1, channels, kh, kw)

conv = nn.Conv2d(channels, channels, 1, bias=False)
conv.weight.data.fill_(1.)
output = conv(patches)

tmp = output.view(1, 16, kh*kw).permute(0, 2, 1)
im = F.fold(tmp, (h, w), (kh, kw), 1, 0, (dh, dw))

Note that you would have to build PyTorch from source, since F.fold is not yet available in the binary release.
Let me know, if this works for you.