From 562945c92b0feb56f2c6ea7444ea111ca54318ef Mon Sep 17 00:00:00 2001 From: xiemoyuan Date: Tue, 22 Sep 2020 12:46:10 +0000 Subject: [PATCH] iCafe 9009: Optimize the error message of OP. --- paddle/fluid/operators/gather_tree_op.cc | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/paddle/fluid/operators/gather_tree_op.cc b/paddle/fluid/operators/gather_tree_op.cc index 26f9989121e..f743727a281 100644 --- a/paddle/fluid/operators/gather_tree_op.cc +++ b/paddle/fluid/operators/gather_tree_op.cc @@ -22,18 +22,19 @@ class GatherTreeOp : public framework::OperatorWithKernel { using framework::OperatorWithKernel::OperatorWithKernel; void InferShape(framework::InferShapeContext* ctx) const override { - PADDLE_ENFORCE(ctx->HasInput("Ids"), - "Input(Ids) of GatherTreeOp should not be null."); - PADDLE_ENFORCE(ctx->HasInput("Parents"), - "Input(Parents) of GatherTreeOp should not be null."); - PADDLE_ENFORCE(ctx->HasOutput("Out"), - "Output(Out) of GatherTreeOp should not be null."); + PADDLE_ENFORCE_EQ(ctx->HasInput("Ids"), true, + "Input(Ids) of GatherTreeOp should not be null."); + PADDLE_ENFORCE_EQ(ctx->HasInput("Parents"), true, + "Input(Parents) of GatherTreeOp should not be null."); + PADDLE_ENFORCE_EQ(ctx->HasOutput("Out"), true, + "Output(Out) of GatherTreeOp should not be null."); auto ids_dims = ctx->GetInputDim("Ids"); auto parents_dims = ctx->GetInputDim("Parents"); - PADDLE_ENFORCE(ids_dims == parents_dims, - "The shape of Input(Parents) must be same with the shape of " - "Input(Ids)."); + PADDLE_ENFORCE_EQ( + ids_dims == parents_dims, true, + "The shape of Input(Parents) must be same with the shape of " + "Input(Ids)."); ctx->SetOutputDim("Out", ids_dims); } -- GitLab