Extending Col2Im to support 5-D input tensors

Hi all,

I recently had to work with PyTorch’s Col2Im and Im2Col functions, and I found that Col2Im currently supports only 3D and 4D input.

I think it would be great if Col2Im could be extended to support 5D input, and in case the maintainers agree with me, I would be really happy to go ahead and open an issue to track progress, and implement 5D support myself.

Any thoughts on this? Would it be alright if I open an issue?

Thanks!

Do you mean to support an additional batch dimension?

No, I mean that along with of 2-d output_size and 2-d kernel_size, we support 3-d output_size, and 3-d kernel_size, too.
I am not sure if that would be adding an additional batch dimension?

I apologise if what I am saying is not clear, if you need more clarification, I would be happy to provide an example, too. Thanks!

Gotcha thanks for the clarification. Opening an issue sounds good.

Though apparently there is a library that already implements it here. Manual Implementation of Unrolled 3D Convolutions - #5 by Youngseok0001. I guess the discussion would be whether want to upstream the implementation there?

That is a great way to go forward, but my thought was that as there is already an iterative implementation of Col2Im(that uses for loops), we could extend that itself to support 5D images.

This code in the Onnx Col2Im reference implementation is similar to what I had in mind:

The implementation in Felix Dangel’s library(the one that you mentioned) would in my opinion be difficult to integrate in the existing implementation of Col2Im, because of its use of torch functions on whole tensors, instead of the use of indexing.

Your thoughts on this?

Hi @soulitzer, I went ahead and opened an issue, and cc’d you there. Here’s the link: Support for 5-D output image tensors in `Col2Im`. · Issue #129564 · pytorch/pytorch · GitHub.

Thanks!

Hi @soulitzer! Just a gentle ping. Could you have a look at the issue when you find time? (Linked above).

I’ll then go ahead and start the implementation once we are able to decide if we would want to upstream the existing implementation or I should extend the current one.

Thanks a lot!