zheng-da commented on a change in pull request #13509: Speedup and fix bug for 
dgl_csr_sampling op
URL: https://github.com/apache/incubator-mxnet/pull/13509#discussion_r239713618
 
 

 ##########
 File path: src/operator/contrib/dgl_graph.cc
 ##########
 @@ -597,74 +584,74 @@ static void SampleSubgraph(const NDArray &csr,
     node.level = 0;
     node_queue.push(node);
   }
-  std::vector<dgl_id_t> tmp_src_list;
-  std::vector<dgl_id_t> tmp_edge_list;
   std::vector<dgl_id_t> tmp_sampled_src_list;
   std::vector<dgl_id_t> tmp_sampled_edge_list;
-  std::unordered_map<dgl_id_t, neigh_list> neigh_mp;
+  // ver_id, position
+  std::unordered_map<dgl_id_t, size_t> neigh_pos;
+  std::vector<dgl_id_t> neighbor_list;
   size_t num_edges = 0;
+  // BFS traverse
   while (!node_queue.empty() &&
-    sub_vertices_count <= max_num_vertices ) {
+         sub_vertices_count < max_num_vertices) {
     ver_node& cur_node = node_queue.front();
     dgl_id_t dst_id = cur_node.vertex_id;
-    if (cur_node.level < num_hops) {
-      auto ret = sub_ver_mp.find(dst_id);
-      if (ret != sub_ver_mp.end()) {
-        node_queue.pop();
-        continue;
-      }
-      tmp_src_list.clear();
-      tmp_edge_list.clear();
-      tmp_sampled_src_list.clear();
-      tmp_sampled_edge_list.clear();
-      GetSrcList(val_list,
-                 col_list,
-                 indptr,
-                 dst_id,
-                 &tmp_src_list,
-                 &tmp_edge_list);
-      if (probability == nullptr) {  // uniform-sample
-        GetUniformSample(tmp_src_list,
-                       tmp_edge_list,
+    auto ret = sub_ver_mp.find(dst_id);
+    if (ret != sub_ver_mp.end()) {
 
 Review comment:
   why do we need a lookup here? if a node is pushed to the queue, it shouldn't 
exist in the table.

----------------------------------------------------------------
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

Reply via email to