未验证 提交 00554b3f 编写于 作者: P pangyoki 提交者: GitHub

fix error message of Inplace strategy (#30520)

上级 d849ecc0
...@@ -221,13 +221,16 @@ void BasicEngine::PrepareGradAccumulators( ...@@ -221,13 +221,16 @@ void BasicEngine::PrepareGradAccumulators(
void BasicEngine::PrepareDeps() { void BasicEngine::PrepareDeps() {
PADDLE_ENFORCE_EQ( PADDLE_ENFORCE_EQ(
node_deps_.empty(), true, node_deps_.empty(), true,
platform::errors::AlreadyExists("Op deps must be initialized.")); platform::errors::AlreadyExists("Op deps are not empty before preparing "
PADDLE_ENFORCE_EQ( "it for backward network execution."));
accumulators_.empty(), true, PADDLE_ENFORCE_EQ(accumulators_.empty(), true,
platform::errors::AlreadyExists("Accumulators must be initialized.")); platform::errors::AlreadyExists(
PADDLE_ENFORCE_EQ( "Accumulators are not empty before preparing it for "
accumulators_with_grad_node_.empty(), true, "backward network execution."));
platform::errors::AlreadyExists("Accumulators must be initialized.")); PADDLE_ENFORCE_EQ(accumulators_with_grad_node_.empty(), true,
platform::errors::AlreadyExists(
"Accumulators with grad_node as the key are not empty "
"before preparing it for backward network execution."));
std::queue<GradOpNode*> q; std::queue<GradOpNode*> q;
std::unordered_set<GradOpNode*> visited; std::unordered_set<GradOpNode*> visited;
......
...@@ -258,11 +258,13 @@ class VariableWrapper { ...@@ -258,11 +258,13 @@ class VariableWrapper {
auto shared_node = grad_node_.lock(); auto shared_node = grad_node_.lock();
if (shared_node != grad_node) { if (shared_node != grad_node) {
PADDLE_ENFORCE_EQ( if (grad_node->InplaceGradNameMap().empty()) {
!shared_node || !grad_node->InplaceGradNameMap().empty(), true, // grad_node doesn't have Inplace message
platform::errors::PermissionDenied( PADDLE_ENFORCE_EQ(
"Cannot set gradient op twice unless using Inplace Strategy.")); shared_node, nullptr,
if (shared_node) { platform::errors::PermissionDenied(
"Cannot set gradient op twice unless using Inplace Strategy."));
} else if (shared_node) {
VLOG(3) << "The gradient op of Var (" << Name() VLOG(3) << "The gradient op of Var (" << Name()
<< ") has been set twice. Because Inplace Strategy is used."; << ") has been set twice. Because Inplace Strategy is used.";
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册