Commit 97ca4a69 authored by Wenzhe Xue's avatar Wenzhe Xue Committed by Scott Cyphers

refactor topological_sort to use Node.get_users() (#2536)

* use Node.get_users() to replace deprecated func

* use const ref instead of auto

* used const auto& in graph_util.cpp
parent f5b296d0
......@@ -185,7 +185,7 @@ bool ngraph::is_post_dominated(Node* X, Node* Y)
stack.pop_front();
if (curr != Y)
{
for (auto next : curr->get_users())
for (const auto& next : curr->get_users())
{
if (visited.count(next.get()) == 0)
{
......@@ -458,7 +458,7 @@ NodeVector ngraph::get_subgraph_outputs(const NodeVector& nodes,
continue;
}
for (auto u : n->get_users())
for (const auto& u : n->get_users())
{
if (nodes_set.count(u) == 0 && (!ignore_unused || is_used(u.get())))
{
......@@ -487,7 +487,7 @@ bool ngraph::is_used(Node* node)
instances_seen.insert(n);
}
stack.pop_front();
for (auto arg : n->get_users())
for (const auto& arg : n->get_users())
{
if (instances_seen.count(arg.get()) == 0)
{
......@@ -501,7 +501,7 @@ bool ngraph::is_used(Node* node)
size_t ngraph::get_user_count(Node* node)
{
size_t count = 0;
for (auto node_user : node->get_users())
for (const auto& node_user : node->get_users())
{
count += is_used(node_user.get());
}
......
......@@ -96,17 +96,11 @@ namespace ngraph
result_list.push_back(node_map[independent_node]);
independent_nodes.pop_front();
for (auto& output : independent_node->get_outputs())
for (const std::shared_ptr<Node>& user : independent_node->get_users())
{
for (auto& input : output.get_inputs())
if (--node_dependency_count[user.get()] == 0)
{
auto user = input->get_raw_pointer_node();
node_dependency_count[user] -= 1;
size_t count = node_dependency_count[user];
if (count == 0)
{
independent_nodes.push_back(user);
}
independent_nodes.push_back(user.get());
}
}
......@@ -179,17 +173,11 @@ namespace ngraph
result_list.push_back(node_map[independent_node]);
independent_nodes.pop_front();
for (auto& output : independent_node->get_outputs())
for (const std::shared_ptr<Node>& user : independent_node->get_users())
{
for (auto& input : output.get_inputs())
if (--node_dependency_count[user.get()] == 0)
{
auto user = input->get_raw_pointer_node();
node_dependency_count[user] -= 1;
size_t count = node_dependency_count[user];
if (count == 0)
{
independent_nodes.push_back(user);
}
independent_nodes.push_back(user.get());
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment