未验证 提交 40b3e752 编写于 作者: P pangyoki 提交者: GitHub

[Cherry-pick] PR 30520. fix error message of Inplace strategy (#30520) (#30568)

Cherry pick PR #30520 .
Fix error message of Inplace strategy.
上级 0ea41e62
......@@ -215,13 +215,16 @@ void BasicEngine::PrepareGradAccumulators(
void BasicEngine::PrepareDeps() {
PADDLE_ENFORCE_EQ(
node_deps_.empty(), true,
platform::errors::AlreadyExists("Op deps must be initialized."));
PADDLE_ENFORCE_EQ(
accumulators_.empty(), true,
platform::errors::AlreadyExists("Accumulators must be initialized."));
PADDLE_ENFORCE_EQ(
accumulators_with_grad_node_.empty(), true,
platform::errors::AlreadyExists("Accumulators must be initialized."));
platform::errors::AlreadyExists("Op deps are not empty before preparing "
"it for backward network execution."));
PADDLE_ENFORCE_EQ(accumulators_.empty(), true,
platform::errors::AlreadyExists(
"Accumulators are not empty before preparing it for "
"backward network execution."));
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::unordered_set<GradOpNode*> visited;
......
......@@ -257,11 +257,13 @@ class VariableWrapper {
auto shared_node = grad_node_.lock();
if (shared_node != grad_node) {
if (grad_node->InplaceGradNameMap().empty()) {
// grad_node doesn't have Inplace message
PADDLE_ENFORCE_EQ(
!shared_node || !grad_node->InplaceGradNameMap().empty(), true,
shared_node, nullptr,
platform::errors::PermissionDenied(
"Cannot set gradient op twice unless using Inplace Strategy."));
if (shared_node) {
} else if (shared_node) {
VLOG(3) << "The gradient op of Var (" << Name()
<< ") 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.
先完成此消息的编辑!
想要评论请 注册