From f6653c71e978128b635a25534182ba2dfb465b0e Mon Sep 17 00:00:00 2001 From: Jacek Czaja Date: Fri, 4 Sep 2020 16:22:59 +0200 Subject: [PATCH] [oneDNN] Fix to conv2d grad with groups (#27006) * - Added fix to mobilenet * - compilation fix * - Fix to conv2d grad oneDNN with groups test=develop --- paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc index aba32c6ec92..19ee8764e27 100644 --- a/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc @@ -1055,7 +1055,11 @@ class ConvMKLDNNGradOpKernel : public paddle::framework::OpKernel { astream.wait(); filter_grad->set_layout(DataLayout::kMKLDNN); - filter_grad->set_format(GetMKLDNNFormat(*diff_weights_memory_p)); + // in OneDNN groups in convolution are treated as separate dimension + // which is not the case in paddlepaddle + auto filter_fmt = GetMKLDNNFormat(*diff_weights_memory_p); + filter_grad->set_format(platform::MKLDNNFormatForSize( + g > 1 ? weights_tz.size() - 1 : weights_tz.size(), filter_fmt)); } if (input_grad) { auto weights_memory_p = handler.AcquireWeightsMemoryFromDataPrimitive( -- GitLab