Unverified Commit f0810b5f authored by Matthew Brookhart's avatar Matthew Brookhart Committed by GitHub

Fix a bug in traverse Nodes (#288)

* We were pushing parameters that have been seen to the stack in traverse nodes. This causes an infinite loop in RNNs.

* fix formatting

* style fix for Scott
parent 7b305e3e
...@@ -159,17 +159,20 @@ void ngraph::traverse_nodes(ngraph::Function* p, std::function<void(shared_ptr<N ...@@ -159,17 +159,20 @@ void ngraph::traverse_nodes(ngraph::Function* p, std::function<void(shared_ptr<N
while (stack.size() > 0) while (stack.size() > 0)
{ {
shared_ptr<Node> n = stack.front(); shared_ptr<Node> n = stack.front();
if (instances_seen.find(n) == instances_seen.end()) if (instances_seen.count(n) == 0)
{ {
instances_seen.insert(n); instances_seen.insert(n);
f(n); f(n);
} }
stack.pop_front(); stack.pop_front();
for (auto arg : n->get_arguments()) for (auto arg : n->get_arguments())
{
if (instances_seen.count(arg) == 0)
{ {
stack.push_front(arg); stack.push_front(arg);
} }
} }
}
} }
void ngraph::traverse_functions(std::shared_ptr<ngraph::Function> p, void ngraph::traverse_functions(std::shared_ptr<ngraph::Function> p,
......
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