未验证 提交 54bf3f5a 编写于 作者: H Huihuang Zheng 提交者: GitHub

Refine PADDLE_ENFORCE Error Messages. test=develop (#30149)

Improve some error messages in parallel_executor.cc, conditional_block_op.cc, recurrent_op.cc
上级 d0fb06b2
...@@ -167,7 +167,9 @@ class ParallelExecutorPrivate { ...@@ -167,7 +167,9 @@ class ParallelExecutorPrivate {
nccl_id = new ncclUniqueId(); nccl_id = new ncclUniqueId();
PADDLE_ENFORCE_EQ( PADDLE_ENFORCE_EQ(
platform::dynload::ncclGetUniqueId(nccl_id), ncclSuccess, platform::dynload::ncclGetUniqueId(nccl_id), ncclSuccess,
platform::errors::PreconditionNotMet("Get NCCL unique ID failed.")); platform::errors::PreconditionNotMet(
"PaddlePaddle failed to get NCCL unique ID. It may due to your "
"system settings or NCCL library error, please debug on NCCL"));
VLOG(10) << "can't find nccl_id_var:" << var_name VLOG(10) << "can't find nccl_id_var:" << var_name
<< ", nccl_id:" << nccl_id; << ", nccl_id:" << nccl_id;
} }
......
...@@ -57,8 +57,10 @@ class ConditionalBlockOp : public ConditionalOp { ...@@ -57,8 +57,10 @@ class ConditionalBlockOp : public ConditionalOp {
if (need_run) { if (need_run) {
auto *scope_var = scope.FindVar(Output(ConditionalOp::kScope)); auto *scope_var = scope.FindVar(Output(ConditionalOp::kScope));
PADDLE_ENFORCE_NOT_NULL( PADDLE_ENFORCE_NOT_NULL(
scope_var, platform::errors::PreconditionNotMet( scope_var,
"Scope must be set in conditional_block_op.")); platform::errors::PreconditionNotMet(
"Expect Scope variable to be set in conditional_block_op, but "
"got a null Scope variable. Please set the Scope variable."));
auto *scopes = scope_var->GetMutable<std::vector<framework::Scope *>>(); auto *scopes = scope_var->GetMutable<std::vector<framework::Scope *>>();
scopes->resize(1); scopes->resize(1);
scopes->front() = &scope.NewScope(); scopes->front() = &scope.NewScope();
...@@ -119,12 +121,16 @@ class ConditionalBlockGradOp : public ConditionalOp { ...@@ -119,12 +121,16 @@ class ConditionalBlockGradOp : public ConditionalOp {
auto *scope_var = scope.FindVar(Input(ConditionalOp::kScope)); auto *scope_var = scope.FindVar(Input(ConditionalOp::kScope));
PADDLE_ENFORCE_NOT_NULL( PADDLE_ENFORCE_NOT_NULL(
scope_var, platform::errors::PreconditionNotMet( scope_var,
"Scope must be set in conditional block op.")); platform::errors::PreconditionNotMet(
"Expect Scope variable to be set in conditional_block_op, but "
"got a null Scope variable. Please set the Scope variable."));
auto &scopes = scope_var->Get<std::vector<framework::Scope *>>(); auto &scopes = scope_var->Get<std::vector<framework::Scope *>>();
PADDLE_ENFORCE_GT(scopes.size(), 0, PADDLE_ENFORCE_GT(
scopes.size(), 0,
platform::errors::InvalidArgument( platform::errors::InvalidArgument(
"Scope must be set in conditional block op.")); "Expect Scope variable contains at least 1 scope, but got: %d",
scopes.size()));
framework::Scope &cur_scope = *scopes[0]; framework::Scope &cur_scope = *scopes[0];
framework::Executor exec(dev_place); framework::Executor exec(dev_place);
......
...@@ -161,7 +161,9 @@ int64_t RecurrentBase::GetSequenceLength(const framework::Scope &scope) const { ...@@ -161,7 +161,9 @@ int64_t RecurrentBase::GetSequenceLength(const framework::Scope &scope) const {
} }
PADDLE_ENFORCE_GE(seq_len, 0, PADDLE_ENFORCE_GE(seq_len, 0,
platform::errors::InvalidArgument( platform::errors::InvalidArgument(
"RecurrentOp gets invalid sequence length.")); "RecurrentOp gets invalid sequence length. Expected "
"seq_len >= 0. Received seq_len = %d",
seq_len));
return seq_len; return seq_len;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册