Channels last with Conv1d

Is possible to use a channel last memory layout with libtorch? I see it’s possible with PyTorch (beta) Channels Last Memory Format in PyTorch — PyTorch Tutorials 1.12.1+cu102 documentation but I don’t see a torch::channels_last or anything with ConvFuncOption.

You could use at::MemoryFormat::ChannelsLast in C++.

Do you have an example @ptrblck conv->to takes either a torch::Dtype or a torch::Device?

I think you could use x.contiguous(at::MemoryFormat::ChannelsLast);

That works for input tensors x but the module parameters are still in at::MemoryFormat::Contigous and I’d really like to avoid the cost of cudnn::ops::nchwToNhwcKernel and cudnn::ops::nhwcToNchwKernel.

If the inputs are already in channels last then checks should also transform the parameters (if available) to the same memory format in intermediate layers. However, you should also be able to explicitly transform these parameters with the same call in a no_grad context.