From b546438c4e5cafb4a7a5d4967075004c4c8e6b5a Mon Sep 17 00:00:00 2001 From: wenbin Date: Mon, 21 Nov 2022 11:14:38 +0800 Subject: [PATCH] round (#48107) --- paddle/fluid/inference/tensorrt/convert/scale_op.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/inference/tensorrt/convert/scale_op.cc b/paddle/fluid/inference/tensorrt/convert/scale_op.cc index 361ed223955..a2cf5b487ce 100644 --- a/paddle/fluid/inference/tensorrt/convert/scale_op.cc +++ b/paddle/fluid/inference/tensorrt/convert/scale_op.cc @@ -53,7 +53,8 @@ class ScaleOpConverter : public OpConverter { nvinfer1::ILayer* layer = nullptr; if (engine_->with_dynamic_shape()) { nvinfer1::ITensor* bias_tensor = - is_int ? Add1DConstantLayer(static_cast(bias)) + is_int ? Add1DConstantLayer( + static_cast(bias > 0 ? bias + 0.5 : bias - 0.5)) : Add1DConstantLayer(bias); bool is_bias_0 = (bias < 1e-06 && bias > -1e-06); @@ -75,7 +76,8 @@ class ScaleOpConverter : public OpConverter { is_scale_1 = false; } else { has_scale_tensor = false; - scale_tensor = is_int ? Add1DConstantLayer(static_cast(scale)) + scale_tensor = is_int ? Add1DConstantLayer(static_cast( + scale > 0 ? scale + 0.5 : scale - 0.5)) : Add1DConstantLayer(scale); is_scale_1 = ((scale - 1.0) < 1e-06 && (scale - 1.0) > -1e-06); } -- GitLab