From 09ade2f26597a52851eff6da272f7eec122f3c3c Mon Sep 17 00:00:00 2001 From: Zihao Ye <expye@outlook.com> Date: Fri, 6 Mar 2020 14:17:48 +0800 Subject: [PATCH] upd (#1321) --- docs/source/developer/ffi.rst | 3 ++- python/dgl/data/graph_serialize.py | 3 ++- python/dgl/graph.py | 4 ++-- python/dgl/model_zoo/chem/gnn.py | 2 +- tests/compute/test_transform.py | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/source/developer/ffi.rst b/docs/source/developer/ffi.rst index bd99f9d05a0c..489fcab3f565 100644 --- a/docs/source/developer/ffi.rst +++ b/docs/source/developer/ffi.rst @@ -217,4 +217,5 @@ out their price: Please note that containers are NOT meant for passing a large collection of items from/to C APIs. It will be quite slow in these cases. It is recommended to benchmark first. As an alternative, use NDArray for a large collection of -numerical values and use BatchedDGLGraph for a lot of graphs. +numerical values and use ``dgl.batch`` to batch a lot of ``DGLGraph``'s into +a single ``DGLGraph``. diff --git a/python/dgl/data/graph_serialize.py b/python/dgl/data/graph_serialize.py index 2b2914aabaf4..0bed262c101b 100644 --- a/python/dgl/data/graph_serialize.py +++ b/python/dgl/data/graph_serialize.py @@ -28,7 +28,8 @@ class GraphData(ObjectBase): @staticmethod def create(g: DGLGraph): """Create GraphData""" - assert g.batch_size == 1, "BatchedDGLGraph is not supported for serialization" + # TODO(zihao): support serialize batched graph in the future. + assert g.batch_size == 1, "Batched DGLGraph is not supported for serialization" ghandle = g._graph if len(g.ndata) != 0: node_tensors = dict() diff --git a/python/dgl/graph.py b/python/dgl/graph.py index 2cd02eafafac..639cf706e65a 100644 --- a/python/dgl/graph.py +++ b/python/dgl/graph.py @@ -962,7 +962,7 @@ def __init__(self, self._batch_num_nodes = batch_num_nodes self._batch_num_edges = batch_num_edges - # set parent if the graph is a induced subgraph. + # set parent if the graph is a subgraph. self._parent = parent def _create_subgraph(self, sgi, induced_nodes, induced_edges): @@ -1893,7 +1893,7 @@ def batch_num_edges(self): @property def parent(self): - """If current graph is a induced subgraph of a parent graph, return + """If current graph is a subgraph of a parent graph, return its parent graph, else return None. Returns diff --git a/python/dgl/model_zoo/chem/gnn.py b/python/dgl/model_zoo/chem/gnn.py index f25d6634ee69..d6a50a246ec7 100644 --- a/python/dgl/model_zoo/chem/gnn.py +++ b/python/dgl/model_zoo/chem/gnn.py @@ -110,7 +110,7 @@ def forward(self, bg, feats): Parameters ---------- - bg : BatchedDGLGraph + bg : DGLGraph Batched DGLGraphs for processing multiple molecules in parallel feats : FloatTensor of shape (N, M1) * N is the total number of atoms in the batched graph diff --git a/tests/compute/test_transform.py b/tests/compute/test_transform.py index 973c96e63995..493d55b2ee2e 100644 --- a/tests/compute/test_transform.py +++ b/tests/compute/test_transform.py @@ -167,7 +167,7 @@ def test_laplacian_lambda_max(): g = dgl.DGLGraph(nx.erdos_renyi_graph(N, 0.3)) l_max = dgl.laplacian_lambda_max(g) assert (l_max[0] < 2 + eps) - # test BatchedDGLGraph + # test batched DGLGraph N_arr = [20, 30, 10, 12] bg = dgl.batch([ dgl.DGLGraph(nx.erdos_renyi_graph(N, 0.3))