From 14a32bf0c471ffee0e76950f35262c7aeb5ec7fe Mon Sep 17 00:00:00 2001 From: Yihua Xu Date: Fri, 7 Jun 2019 13:53:59 +0800 Subject: [PATCH] Fix the accuracy issue while using float precision to get the scale. (#17884) test=develop --- paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc index 01540e0ef28..25bd6a9ead2 100644 --- a/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/conv_mkldnn_op.cc @@ -429,7 +429,9 @@ class ConvMKLDNNOpKernel : public paddle::framework::OpKernel { // scale couldn't be calculated else output_shift_scale[i] = - scale_out_data / (scale_in_data * scale_weights_data[i]); + static_cast(static_cast(scale_out_data) / + (static_cast(scale_in_data) * + static_cast(scale_weights_data[i]))); } auto user_src_md = -- GitLab