oneDNN icon indicating copy to clipboard operation
oneDNN copied to clipboard

Slow with 1x1 kernel conv

Open tensor-tang opened this issue 9 years ago • 3 comments

Found a performance issue:

I just run only one test case below, which is the res5a_branch1_conv in ResNet50. PARAMS(FMT_DATA_BLOCKED, FMT_WEIGHTS_BLOCKED, FMT_NO_BIAS, FMT_DATA_BLOCKED, 64, 1, 1024, 14, 14, 2048, 7, 7, 1, 1, 0, 0, 2, 2)

BTW, need change Line 49 at Convolution_common.h #define FMT_NO_BIAS format_undef

But it takes about 10 seconds computing backward data on E5-2699 v4, is that normal? Time between: stream(stream::kind::eager).submit(pipeline).wait(); I suppose it should be several ms.

tensor-tang avatar Mar 15 '17 02:03 tensor-tang

Hi,

That is normal for specified convolution parameters (non-unit strides) and data format (nChw8c). MKL-DNN optimized backward data propagation for convolutions with non-unit strides uses memory format "nchw". For above case mkl-dnn falls back to reference implementation that is very slow. In real usage it is preferable to specify format "any" to enable convolution primitive to choose the data format that is most suitable for its input parameters (convolution kernel sizes, strides, padding, and so on). If the resulting format is different from the original format , data needs to be transformed to the format required for the convolution.

Thanks for remark regarding FMT_NO_BIAS format definition. It will be fixed.

ankalinin avatar Mar 17 '17 21:03 ankalinin

Updated FMT_NO_BIAS definition in 00f2ee4bd030309111253eb6cbd2cbaddf7aa504.

vpirogov avatar Mar 18 '17 00:03 vpirogov

Thanks @ankalinin, @vpirogov.

Yes indeed, the recommend format returned is nchw here.

However, this specific layer it is effective if use any format here, but for the whole topology like Resnet and Googlenet, many reorders between nchw and nChw8c are needed then. I thought this kind of converting are so unnecessary for the whole picture.

So I was wondering that some better implements with nChw8c/nChw16c for 1x1 kernel ? Then it could have better performance, saving much more reorder time.

Thanks.

tensor-tang avatar Mar 18 '17 08:03 tensor-tang