From 534beb5ac77ee484ebc0e83966df89d7064df5a7 Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Mon, 15 Apr 2019 03:30:59 +0000 Subject: [PATCH] fix for itnerpolate. test=release/1.4 --- paddle/fluid/operators/interpolate_op.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/paddle/fluid/operators/interpolate_op.cc b/paddle/fluid/operators/interpolate_op.cc index 9d9924a6baa..0d43213f960 100644 --- a/paddle/fluid/operators/interpolate_op.cc +++ b/paddle/fluid/operators/interpolate_op.cc @@ -40,6 +40,8 @@ class InterpolateOp : public framework::OperatorWithKernel { int out_h = ctx->Attrs().Get("out_h"); int out_w = ctx->Attrs().Get("out_w"); PADDLE_ENFORCE_EQ(dim_x.size(), 4, "X's dimension must be 4"); + PADDLE_ENFORCE_GT(out_h, 0, "out_h should be greater than 0."); + PADDLE_ENFORCE_GT(out_w, 0, "out_w should be greater than 0."); if (ctx->HasInput("OutSize") && ctx->IsRuntime()) { auto out_size_dim = ctx->GetInputDim("OutSize"); @@ -50,12 +52,8 @@ class InterpolateOp : public framework::OperatorWithKernel { return; } - if (ctx->IsRuntime() || (out_h > 0 && out_w > 0)) { - std::vector dim_out({dim_x[0], dim_x[1], out_h, out_w}); - ctx->SetOutputDim("Out", framework::make_ddim(dim_out)); - } else { - ctx->SetOutputDim("Out", dim_x); - } + std::vector dim_out({dim_x[0], dim_x[1], out_h, out_w}); + ctx->SetOutputDim("Out", framework::make_ddim(dim_out)); } protected: -- GitLab