forked from dmlc/dgl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] add NodeFlow API (dmlc#361)
* sample layer subgraphs. * fix. * fix. * add layered subgraph. * fix lint. * fix. * fix tutorial. * fix. * remove copy_to_parent. * add num_layers * move sampling code to sampler.cc * fix. * move subgraph construction out. * Revert "move subgraph construction out." This reverts commit 24b3d13. * change to NodeFlow. * use NodeFlow in Python. * use NodeFlowIndex. * add node_mapping and edge_mapping. * remove unnecessary code in SSE tutorial. * Revert "remove unnecessary code in SSE tutorial." This reverts commit 093f041. * fix tutorial. * move to node_flow. * update gcn cv updater. * import NodeFlow. * update. * add demo code for vanilla control variate sampler. * update. * update. * add neighbor sampling. * return flow offsets. * update node_flow. * add test. * fix sampler. * fix graph index. * fix a bug in sampler. * fix map_to_layer_nid and map_to_flow_eid. * fix apply_flow. * remove model code. * implement flow_compute. * fix a bug. * reverse the csr physically. * add mini-batch test. * add mini batch test. * update flow_compute. * add prop_flows * run on specific nodes. * test copy * fix a bug in creating frame in NodeFlow. * add init gcn_cv_updater. * fix a minor bug. * fix gcn_cv_updater. * fix a bug. * fix a bug in NodeFlow. * use new h in gcn_cv_updater. * add layer_in_degree and layer_out_degree. * fix gcn_cv_updater for gpu. * temp fix in NodeFlow for diff context. * allow enabling/disabling copy back. * add with-updater option. * fix a bug in computing degree. * add with-cv option. * rename and add comments. * fix lint complain. * fix lint. * avoid assert. * remove assert. * fix. * fix. * fix. * fix. * fix the methods in NodeFlow. * fix lint. * update SSE. * remove gcn_cv_updater. * correct comments for the schedulers. * update comment. * add map_to_nodeflow_nid * address comment. * remove duplicated test. * fix int. * fix comments. * fix lint * fix. * replace subgraph with NodeFlow. * move view. * address comments. * fix lint. * fix lint. * remove static_cast. * fix docstring. * fix comments. * break SampleSubgraph. * move neighbor sampling to sampler.cc * fix comments. * rename. * split neighbor_list. * address comments. * fix. * remove TODO.
- Loading branch information
Showing
20 changed files
with
2,812 additions
and
1,376 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/*! | ||
* Copyright (c) 2018 by Contributors | ||
* \file dgl/sampler.h | ||
* \brief DGL sampler header. | ||
*/ | ||
#ifndef DGL_SAMPLER_H_ | ||
#define DGL_SAMPLER_H_ | ||
|
||
#include "graph_interface.h" | ||
|
||
namespace dgl { | ||
|
||
class ImmutableGraph; | ||
|
||
/*! | ||
* \brief A NodeFlow graph stores the sampling results for a sampler that samples | ||
* nodes/edges in layers. | ||
* | ||
* We store multiple layers of the sampling results in a single graph, which results | ||
* in a more compact format. We store extra information, | ||
* such as the node and edge mapping from the NodeFlow graph to the parent graph. | ||
*/ | ||
struct NodeFlow { | ||
/*! \brief The graph. */ | ||
GraphPtr graph; | ||
/*! | ||
* \brief the offsets of each layer. | ||
*/ | ||
IdArray layer_offsets; | ||
/*! | ||
* \brief the offsets of each flow. | ||
*/ | ||
IdArray flow_offsets; | ||
/*! | ||
* \brief The node mapping from the NodeFlow graph to the parent graph. | ||
*/ | ||
IdArray node_mapping; | ||
/*! | ||
* \brief The edge mapping from the NodeFlow graph to the parent graph. | ||
*/ | ||
IdArray edge_mapping; | ||
}; | ||
|
||
class SamplerOp { | ||
public: | ||
/*! | ||
* \brief Sample a graph from the seed vertices with neighbor sampling. | ||
* The neighbors are sampled with a uniform distribution. | ||
* | ||
* \param graphs A graph for sampling. | ||
* \param seeds the nodes where we should start to sample. | ||
* \param edge_type the type of edges we should sample neighbors. | ||
* \param num_hops the number of hops to sample neighbors. | ||
* \param expand_factor the max number of neighbors to sample. | ||
* \return a NodeFlow graph. | ||
*/ | ||
static NodeFlow NeighborUniformSample(const ImmutableGraph *graph, IdArray seeds, | ||
const std::string &edge_type, | ||
int num_hops, int expand_factor); | ||
}; | ||
|
||
} // namespace dgl | ||
|
||
#endif // DGL_SAMPLER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.