From 0f7411a1aec865ada830156c0fc67bf820bf12a5 Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Fri, 29 Mar 2019 08:39:09 +0000 Subject: [PATCH] round down for scale. test=develop --- paddle/fluid/operators/interpolate_op.cc | 5 +++-- paddle/fluid/operators/interpolate_op.h | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/paddle/fluid/operators/interpolate_op.cc b/paddle/fluid/operators/interpolate_op.cc index 7ad3314e8b..5c36048eed 100644 --- a/paddle/fluid/operators/interpolate_op.cc +++ b/paddle/fluid/operators/interpolate_op.cc @@ -41,8 +41,9 @@ class InterpolateOp : public framework::OperatorWithKernel { int out_h, out_w; float scale = ctx->Attrs().Get("scale"); if (scale > 0) { - out_h = dim_x[2] * scale; - out_w = dim_x[3] * scale; + // round down + out_h = static_cast(dim_x[2] * scale); + out_w = static_cast(dim_x[3] * scale); } else { out_h = ctx->Attrs().Get("out_h"); out_w = ctx->Attrs().Get("out_w"); diff --git a/paddle/fluid/operators/interpolate_op.h b/paddle/fluid/operators/interpolate_op.h index dab6269756..5fd42809df 100644 --- a/paddle/fluid/operators/interpolate_op.h +++ b/paddle/fluid/operators/interpolate_op.h @@ -174,8 +174,8 @@ class InterpolateKernel : public framework::OpKernel { float scale = ctx.Attr("scale"); if (scale > 0) { - out_h = in_h * scale; - out_w = in_w * scale; + out_h = static_cast(in_h * scale); + out_w = static_cast(in_w * scale); } auto out_size = ctx.Input("OutSize"); @@ -239,8 +239,8 @@ class InterpolateGradKernel : public framework::OpKernel { float scale = ctx.Attr("scale"); if (scale > 0) { - out_h = in_h * scale; - out_w = in_w * scale; + out_h = static_cast(in_h * scale); + out_w = static_cast(in_w * scale); } auto out_size = ctx.Input("OutSize"); -- GitLab