未验证 提交 ef72de6f 编写于 作者: Z zhaoyuchen2018 提交者: GitHub

API(Print) error message enhancement. test=develop (#23521)

Enhance print op c++ error message.
上级 5b97b855
...@@ -148,10 +148,14 @@ class PrintOp : public framework::OperatorBase { ...@@ -148,10 +148,14 @@ class PrintOp : public framework::OperatorBase {
const platform::Place &place) const override { const platform::Place &place) const override {
const auto in_var = scope.FindVar(Input("In")); const auto in_var = scope.FindVar(Input("In"));
auto out_var = scope.FindVar(Output("Out")); auto out_var = scope.FindVar(Output("Out"));
PADDLE_ENFORCE_NOT_NULL(in_var, "The input should not be found in scope",
Input("In")); PADDLE_ENFORCE_NOT_NULL(
PADDLE_ENFORCE_NOT_NULL(out_var, "The output should not be found in scope", in_var, platform::errors::NotFound("The input:%s not found in scope",
Output("Out")); Input("In")));
PADDLE_ENFORCE_NOT_NULL(
out_var, platform::errors::NotFound("The output:%s not found in scope",
Output("Out")));
auto &in_tensor = in_var->Get<framework::LoDTensor>(); auto &in_tensor = in_var->Get<framework::LoDTensor>();
framework::LoDTensor *out_tensor = framework::LoDTensor *out_tensor =
out_var->GetMutable<framework::LoDTensor>(); out_var->GetMutable<framework::LoDTensor>();
...@@ -246,8 +250,8 @@ class PrintOpInferShape : public framework::InferShapeBase { ...@@ -246,8 +250,8 @@ class PrintOpInferShape : public framework::InferShapeBase {
public: public:
void operator()(framework::InferShapeContext *ctx) const override { void operator()(framework::InferShapeContext *ctx) const override {
VLOG(10) << "PrintOpInferShape"; VLOG(10) << "PrintOpInferShape";
PADDLE_ENFORCE(ctx->HasInput("In"), "Input(In) should not be null."); OP_INOUT_CHECK(ctx->HasInput("In"), "Input", "In", "Print");
PADDLE_ENFORCE(ctx->HasOutput("Out"), "Output(Out) should not be null."); OP_INOUT_CHECK(ctx->HasOutput("Out"), "Output", "Out", "Print");
ctx->ShareDim("In", /*->*/ "Out"); ctx->ShareDim("In", /*->*/ "Out");
ctx->ShareLoD("In", /*->*/ "Out"); ctx->ShareLoD("In", /*->*/ "Out");
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册