This is possibly a feature request.
I’m using nn.Unfold for a custom nn.Conv2d layer. Found the following small issue.
import torch
import torch.nn as nn

a = torch.arange(9, dtype=float).reshape(1,1,3,3)
unfold = nn.Unfold(kernel_size=2)
unfold(a)

Output is
tensor([[[0., 1., 3., 4.],
         [1., 2., 4., 5.],
         [3., 4., 6., 7.],
         [4., 5., 7., 8.]]], dtype=torch.float64)

doing instead
unfold = nn.Unfold(kernel_size=2, padding=1)
unfold(a)

Output then is
tensor([[[0., 0., 0., 0., 0., 0., 1., 2., 0., 3., 4., 5., 0., 6., 7., 8.],
         [0., 0., 0., 0., 0., 1., 2., 0., 3., 4., 5., 0., 6., 7., 8., 0.],
         [0., 0., 1., 2., 0., 3., 4., 5., 0., 6., 7., 8., 0., 0., 0., 0.],
         [0., 1., 2., 0., 3., 4., 5., 0., 6., 7., 8., 0., 0., 0., 0., 0.]]],
       dtype=torch.float64)

As you can see, nn.Unfold automatically considers padding as padding_mode='zeros'.
It does not accept parameters other than kernel_size, dilation, padding and stride.
How should I implement a replicate mode?
Regards
EDIT
Of course I can solve the above using torch.nn.functional.pad. Doing so it will probably create an extra copy though…