I found that conv1d, conv2d, conv3d use ConvNd = torch._C._functions.ConvNd for forward passing. I just want to know whether there is an efficient way to use ConvNd for 4dimension convolution, since my inputs are 4-dimension (6 dimension if count batchsize and channel.)

Since we have the ConvNd function, why canâ€™t we implement a 4d convolution just like the others? Why not n-dimensional?

From the Python side, all the convolution layers ultimately delegate to that ConvNd function. Nothing seems special cased for any particular kernel shape.

I think the C++ side is implemented at torch/csrc/autograd/functions/convolution.{h,cpp}. The forward pass has a special case when n=3, but all it seems to do is reshape the kernel by adding/removing dummy dimensions. Iâ€™m not entirely sure why though. Perhaps it could be easily generalized? Iâ€™m a bit out of my element with these low-level details, so I may be missing something.

itâ€™s mostly that we havenâ€™t implemented the C bits going for ConvNd in the THNN/THCUNN libraries. (untimately autograd/functions/convolution.cpp dispatches to that or to CuDNN).

@Edward_Hahn not really, because the demand for 4d convolution is not high. Your best bet is to create N Conv3D layers to do a Conv4D (there will be some boundary effects / issues, so you will have to pad edges appropriately)

Just wanted to chime in and say that Iâ€™m interested in this feature, it seems like the natural way to represent time series of multi-channel satellite images.

Wouldnâ€™t this correspond to a 3D convolution, where the input would have the shape [batch_size, in_channels, seq, height, width] or is each â€śimageâ€ť a volume?

Here you can find a fully functional convNd and nD transposed convolution based on conv3d as mentioned by smth.

But Iâ€™m also looking forward to a native 4D convolution, mainly due to speed concerns. Iâ€™m starting with the implementation, but indeed seems like a long way to go.

Iâ€™d also LOVE to see this implemented. In my case, itâ€™s a natural way to represent a time series of 3D dimensional microscopy measurements. Hope the pytorch team will consider implementing it.