Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
initialize visited set with snodes
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrookhart authored and mbrookhart committed Sep 12, 2018
1 parent 7bc5988 commit 61bcdd1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/operator/subgraph/partition_graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ bool LabelSubgraph(const Graph& g,
const std::vector<nnvm::Node*>& snodes) {
if (ancestor == descendant) return true;
std::stack<const nnvm::Node*> s;
std::unordered_set<const nnvm::Node*> visited;
std::unordered_set<const nnvm::Node*> visited(snodes.begin(), snodes.end());
s.push(descendant);
size_t count = 0;
while (!s.empty()) {
Expand All @@ -253,6 +253,8 @@ bool LabelSubgraph(const Graph& g,
return true;
}
for (const auto& entry : top->inputs) {
// when searching for the ancestor, the path cannot cross any subgraph node
// or a previously visited node
if (visited.count(entry.node.get()) == 0) {
s.push(entry.node.get());
}
Expand Down

0 comments on commit 61bcdd1

Please sign in to comment.