balbasty / nitorch

Neuroimaging in PyTorch
Other
83 stars 14 forks source link

Convolution with boundary conditions #4

Open balbasty opened 4 years ago

balbasty commented 4 years ago

PyTorch's convolutions return domain is the joint domain of the input tensor and kernel. This means that the tensor is implicitly cropped by an amount that corresponds to the kernel size. Furthermore, padding mode other than zero trigger an allocation.

I propose to implement a nitorch-specific convolution that is more in-line with the behaviour of spm's vel2mom, where the output domain is the same as the input domain (up to strides), and boundary conditions are handled on the fly. Such an implementation cannot use CuDNN, so will be slower than PyTorch's version, but will make gradient-based regularisers easier to implement.

This feature is in active development in banch conv.