Problem using NHWC layout format in cuDNN


I tried to perform a convolution with cudnnConvolutionForward(…).
My data is described with NHWC layout format.
But cuDNN seems to always interprets my filter with NCHW layer format even if I use the CUDNN_TENSOR_NHWC flag.

Example of what I have done to define the filter in NHWC :

   cudnnFilterDescriptor_t kernel_descriptor;
                                         dataType= CUDNN_DATA_FLOAT,
                                         format= CUDNN_TENSOR_NHWC,
                                         out_channels= 3,
                                         in_channels= 1,
                                         kernel_height= 1,
                                         kernel_width = 3));

//const float h_kernel[width][channels] 
const float h_kernel[3][3] = {{channel1_value1, channel2_value1, channel3_value1}, \
                              {channel1_value2, channel2_value2, channel3_value2}, \
                              {channel1_value3, channel2_value3, channel3_value3}};

Am I mistaken somewhere ?

Do we need to put the data in memory in a certain way or is it the same declaration for NCHW and NHWC, and cuDNN perform the layer data layout change under the hood ?

Thanks in advance.

Hi @julie.fraysse ,
c in nhwc is in_channels, not out_channels
[out_channels, in_channels, kernel_height, kernel_width] correspond to [n, c, h, w]
Plesae try that and let us know if the issue still occurs.

Thanks for your help @AakankshaS