From 9b666cae67b39903bb8a744eb6ee51f0d59aeb51 Mon Sep 17 00:00:00 2001 From: Liufang Sang Date: Mon, 4 Nov 2019 10:06:13 +0800 Subject: [PATCH] fix diff in dequantize op between cpu and gpu test=develop (#20953) --- paddle/fluid/operators/fake_dequantize_op.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/operators/fake_dequantize_op.cc b/paddle/fluid/operators/fake_dequantize_op.cc index e01adae4dd8..cd094577e6b 100644 --- a/paddle/fluid/operators/fake_dequantize_op.cc +++ b/paddle/fluid/operators/fake_dequantize_op.cc @@ -29,7 +29,7 @@ struct DequantizeFunctor { auto out_e = framework::EigenVector::Flatten(*out); auto& dev = *dev_ctx.eigen_device(); - out_e.device(dev) = (scale_factor[0] / max_range) * in_e; + out_e.device(dev) = scale_factor[0] * in_e / max_range; } }; @@ -48,7 +48,7 @@ struct ChannelDequantizeFunctor { auto in_e = framework::EigenVector::Flatten(one_channel_in); auto out_e = framework::EigenVector::Flatten(one_channel_out); auto& dev = *dev_ctx.eigen_device(); - out_e.device(dev) = (s / max_range) * in_e; + out_e.device(dev) = s * in_e / max_range; } } else if (scale_num == 2) { int batch_size = in->dims()[0]; @@ -67,7 +67,7 @@ struct ChannelDequantizeFunctor { auto in_e = framework::EigenVector::Flatten(one_channel_in); auto out_e = framework::EigenVector::Flatten(one_channel_out); auto& dev = *dev_ctx.eigen_device(); - out_e.device(dev) = (s * scale_two[0] / max_range) * in_e; + out_e.device(dev) = (s * scale_two[0]) * in_e / max_range; } } } -- GitLab