diff --git a/paddle/fluid/operators/interpolate_op.cc b/paddle/fluid/operators/interpolate_op.cc index 7ad3314e8b007bf69be1ec53ef849cf6d7593ee1..5c36048eed2b2430689fb7eb54e4cb10caa197ff 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 dab626975659fed82b21754af6f18e7769ef6604..5fd42809dfec6dd821c9b27bc97d61de94b5d326 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");