reminisce commented on a change in pull request #14113: Enhance subgraph API URL: https://github.com/apache/incubator-mxnet/pull/14113#discussion_r269838120
########## File path: src/operator/subgraph/build_subgraph.cc ########## @@ -153,20 +120,23 @@ void ResetNodeLabels(const nnvm::Graph& g, * \subgraph_nodes all the nodes belonging to the same subgraph of seed node * \excluded_nodes set of nodes that should be excluded from the current subgraph */ -bool LabelSubgraph(const Graph& g, - SubgraphSelectorPtr subgraph_selector, - const int label, - const size_t snid, // simple node id, this is a seed - const std::vector<SimpleNodePtr>& simple_nodes, - std::vector<nnvm::Node*>* subgraph_nodes, - std::unordered_set<const nnvm::Node*>* excluded_nodes = nullptr) { +bool LabelSubgraph(const nnvm::Graph& g, SubgraphSelectorV2Ptr subgraph_selector, const int label, + const size_t snid, const std::vector<BiDirectionalNodePtr>& simple_nodes, + std::vector<BiDirectionalNode*>* subgraph_nodes, + std::unordered_set<const BiDirectionalNode*>* excluded_nodes) { const auto& indexed_graph = g.indexed_graph(); - std::queue<SimpleNode*> node_queue; - if (!excluded_nodes || !excluded_nodes->count(simple_nodes[snid]->node)) { - CHECK_EQ(simple_nodes[snid]->label, -1); - simple_nodes[snid]->label = label; - node_queue.push(simple_nodes[snid].get()); - } + std::queue<BiDirectionalNode*> node_queue; + CHECK_EQ(simple_nodes[snid]->label, -1); + simple_nodes[snid]->label = label; + node_queue.push(simple_nodes[snid].get()); + struct hash_pair { + inline size_t operator()( + const std::pair<const BiDirectionalNode*, const BiDirectionalNode*>& v) const { + size_t value = std::hash<const void*>()(v.first); + value ^= std::hash<const void*>()(v.second) + 0x9e3779b9 + (value << 6) + (value >> 2); Review comment: Use `dmlc::HashCombine` to get the hash value of a pair of nodes. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services