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

fix error message of Inplace strategy (#30520)

上级 d849ecc0
......@@ -221,13 +221,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;
......
......@@ -258,11 +258,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.
先完成此消息的编辑!
想要评论请 注册