未验证 提交 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,6 +360,16 @@ std::vector<paddle::experimental::Tensor> RunBackward( ...@@ -360,6 +360,16 @@ 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 (is_general_grad) {
if (node_in_degree_map[next_node] == 0 &&
GeneralGrad::Instance().IsNeededNodes(next_node)) {
if (dynamic_cast<egr::GradNodeAccumulation*>(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 (node_in_degree_map[next_node] == 0) {
if (dynamic_cast<egr::GradNodeAccumulation*>(next_node)) { if (dynamic_cast<egr::GradNodeAccumulation*>(next_node)) {
queue.push_front(std::move(next_node)); queue.push_front(std::move(next_node));
...@@ -370,6 +380,7 @@ std::vector<paddle::experimental::Tensor> RunBackward( ...@@ -370,6 +380,7 @@ std::vector<paddle::experimental::Tensor> RunBackward(
} }
} }
} }
}
VLOG(6) << "Run Backward Final hook size: " VLOG(6) << "Run Backward Final hook size: "
<< egr::Controller::Instance().FinalBackwardHooks().size(); << egr::Controller::Instance().FinalBackwardHooks().size();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册