mbrookhart commented on a change in pull request #12502: [NGRAPH] MXNet -
nGraph initial integration
URL: https://github.com/apache/incubator-mxnet/pull/12502#discussion_r216897698
##########
File path: src/operator/subgraph/partition_graph.cc
##########
@@ -238,21 +239,21 @@ 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;
s.push(descendant);
size_t count = 0;
while (!s.empty()) {
- CHECK_LT(count, indexed_graph.num_nodes()) << "Finding ancestor failed.
There is probably"
- " a loop in the graph";
+ CHECK_LT(count, indexed_graph.num_nodes())
+ << "Finding ancestor failed. There is probably a loop in the graph";
++count;
const nnvm::Node* top = s.top();
s.pop();
+ visited.insert(top);
if (top == ancestor) {
return true;
}
for (const auto& entry : top->inputs) {
- // when searching for the ancestor, the path cannot cross any subgraph
node
- auto it = std::find(snodes.begin(), snodes.end(), entry.node.get());
Review comment:
mmm, missed the snodes feature, for some reason I was thinking snodes was
the set of nodes in the stack. Will initialize the visited variable with snodes.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services