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