未验证 提交 849eccb7 编写于 作者: W Weilong Wu 提交者: GitHub

[Eager] just need to run needed nodes (#44910)

* [Eager] just need to run needed nodes

* [Eager] just need to run needed nodes
上级 ce9d2a9e
...@@ -360,11 +360,22 @@ std::vector<paddle::experimental::Tensor> RunBackward( ...@@ -360,11 +360,22 @@ std::vector<paddle::experimental::Tensor> RunBackward(
"Node's in-degree cannot be negative.", "Node's in-degree cannot be negative.",
next_node->name())); next_node->name()));
if (node_in_degree_map[next_node] == 0) { if (is_general_grad) {
if (dynamic_cast<egr::GradNodeAccumulation*>(next_node)) { if (node_in_degree_map[next_node] == 0 &&
queue.push_front(std::move(next_node)); GeneralGrad::Instance().IsNeededNodes(next_node)) {
} else { if (dynamic_cast<egr::GradNodeAccumulation*>(next_node)) {
queue.push_back(std::move(next_node)); queue.push_front(std::move(next_node));
} else {
queue.push_back(std::move(next_node));
}
}
} else {
if (node_in_degree_map[next_node] == 0) {
if (dynamic_cast<egr::GradNodeAccumulation*>(next_node)) {
queue.push_front(std::move(next_node));
} else {
queue.push_back(std::move(next_node));
}
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册