Unverified Commit 3132da28 authored by peizhou001's avatar peizhou001 Committed by GitHub
Browse files

Deprecate (#4864)

rename DGLHeteroGraph to DGLGraph
parent ee9887d6
...@@ -133,7 +133,7 @@ class WeightedSAGEConv(nn.Module): ...@@ -133,7 +133,7 @@ class WeightedSAGEConv(nn.Module):
class SAGENet(nn.Module): class SAGENet(nn.Module):
def __init__(self, hidden_dims, n_layers): def __init__(self, hidden_dims, n_layers):
""" """
g : DGLHeteroGraph g : DGLGraph
The user-item interaction graph. The user-item interaction graph.
This is only for finding the range of categorical variables. This is only for finding the range of categorical variables.
item_textsets : torchtext.data.Dataset item_textsets : torchtext.data.Dataset
...@@ -357,7 +357,7 @@ def assign_textual_node_features(ndata, textset, ntype): ...@@ -357,7 +357,7 @@ def assign_textual_node_features(ndata, textset, ntype):
The length would be stored as another node feature with name The length would be stored as another node feature with name
``field_name + '__len'``. ``field_name + '__len'``.
block : DGLHeteroGraph block : DGLGraph
First element of the compacted blocks, with "dgl.NID" as the First element of the compacted blocks, with "dgl.NID" as the
corresponding node ID in the original graph, hence the index to the corresponding node ID in the original graph, hence the index to the
text dataset. text dataset.
......
...@@ -88,7 +88,7 @@ class RelGraphConvLayer(nn.Module): ...@@ -88,7 +88,7 @@ class RelGraphConvLayer(nn.Module):
Parameters Parameters
---------- ----------
g : DGLHeteroGraph g : DGLGraph
Input graph. Input graph.
inputs : dict[str, torch.Tensor] inputs : dict[str, torch.Tensor]
Node feature for each node type. Node feature for each node type.
...@@ -164,14 +164,14 @@ class RelGraphEmbed(nn.Module): ...@@ -164,14 +164,14 @@ class RelGraphEmbed(nn.Module):
Parameters Parameters
---------- ----------
block : DGLHeteroGraph, optional block : DGLGraph, optional
If not specified, directly return the full graph with embeddings stored in If not specified, directly return the full graph with embeddings stored in
:attr:`embed_name`. Otherwise, extract and store the embeddings to the block :attr:`embed_name`. Otherwise, extract and store the embeddings to the block
graph and return. graph and return.
Returns Returns
------- -------
DGLHeteroGraph DGLGraph
The block graph fed with embeddings. The block graph fed with embeddings.
""" """
embeds = {} embeds = {}
......
...@@ -67,8 +67,6 @@ Operators for generating new graphs by manipulating the structure of the existin ...@@ -67,8 +67,6 @@ Operators for generating new graphs by manipulating the structure of the existin
add_self_loop add_self_loop
adj_product_graph adj_product_graph
adj_sum_graph adj_sum_graph
as_heterograph
as_immutable_graph
compact_graphs compact_graphs
khop_adj khop_adj
khop_graph khop_graph
......
...@@ -28,7 +28,7 @@ def get_graph(network_data, vocab): ...@@ -28,7 +28,7 @@ def get_graph(network_data, vocab):
mapping node IDs to node indices mapping node IDs to node indices
Output Output
------ ------
DGLHeteroGraph DGLGraph
a heterogenous graph, with one node type and different edge types a heterogenous graph, with one node type and different edge types
""" """
graphs = [] graphs = []
......
...@@ -28,7 +28,7 @@ def get_graph(network_data, vocab): ...@@ -28,7 +28,7 @@ def get_graph(network_data, vocab):
mapping node IDs to node indices mapping node IDs to node indices
Output Output
------ ------
DGLHeteroGraph DGLGraph
a heterogenous graph, with one node type and different edge types a heterogenous graph, with one node type and different edge types
""" """
graphs = [] graphs = []
......
...@@ -39,7 +39,7 @@ def get_graph(network_data, vocab): ...@@ -39,7 +39,7 @@ def get_graph(network_data, vocab):
mapping node IDs to node indices mapping node IDs to node indices
Output Output
------ ------
DGLHeteroGraph DGLGraph
a heterogenous graph, with one node type and different edge types a heterogenous graph, with one node type and different edge types
""" """
graphs = [] graphs = []
......
...@@ -46,25 +46,25 @@ class MovieLens(object): ...@@ -46,25 +46,25 @@ class MovieLens(object):
Attributes Attributes
---------- ----------
train_enc_graph : dgl.DGLHeteroGraph train_enc_graph : dgl.DGLGraph
Encoder graph for training. Encoder graph for training.
train_dec_graph : dgl.DGLHeteroGraph train_dec_graph : dgl.DGLGraph
Decoder graph for training. Decoder graph for training.
train_labels : torch.Tensor train_labels : torch.Tensor
The categorical label of each user-movie pair The categorical label of each user-movie pair
train_truths : torch.Tensor train_truths : torch.Tensor
The actual rating values of each user-movie pair The actual rating values of each user-movie pair
valid_enc_graph : dgl.DGLHeteroGraph valid_enc_graph : dgl.DGLGraph
Encoder graph for validation. Encoder graph for validation.
valid_dec_graph : dgl.DGLHeteroGraph valid_dec_graph : dgl.DGLGraph
Decoder graph for validation. Decoder graph for validation.
valid_labels : torch.Tensor valid_labels : torch.Tensor
The categorical label of each user-movie pair The categorical label of each user-movie pair
valid_truths : torch.Tensor valid_truths : torch.Tensor
The actual rating values of each user-movie pair The actual rating values of each user-movie pair
test_enc_graph : dgl.DGLHeteroGraph test_enc_graph : dgl.DGLGraph
Encoder graph for test. Encoder graph for test.
test_dec_graph : dgl.DGLHeteroGraph test_dec_graph : dgl.DGLGraph
Decoder graph for test. Decoder graph for test.
test_labels : torch.Tensor test_labels : torch.Tensor
The categorical label of each user-movie pair The categorical label of each user-movie pair
......
...@@ -233,7 +233,7 @@ class GCMCLayer(nn.Module): ...@@ -233,7 +233,7 @@ class GCMCLayer(nn.Module):
Parameters Parameters
---------- ----------
graph : DGLHeteroGraph graph : DGLGraph
User-movie rating graph. It should contain two node types: "user" User-movie rating graph. It should contain two node types: "user"
and "movie" and many edge types each for one rating value. and "movie" and many edge types each for one rating value.
ufeat : torch.Tensor, optional ufeat : torch.Tensor, optional
...@@ -320,7 +320,7 @@ class BiDecoder(nn.Module): ...@@ -320,7 +320,7 @@ class BiDecoder(nn.Module):
Parameters Parameters
---------- ----------
graph : DGLHeteroGraph graph : DGLGraph
"Flattened" user-movie graph with only one edge type. "Flattened" user-movie graph with only one edge type.
ufeat : th.Tensor ufeat : th.Tensor
User embeddings. Shape: (|V_u|, D) User embeddings. Shape: (|V_u|, D)
......
...@@ -47,7 +47,7 @@ class HANLayer(nn.Module): ...@@ -47,7 +47,7 @@ class HANLayer(nn.Module):
Inputs Inputs
------ ------
g : DGLHeteroGraph g : DGLGraph
The heterogeneous graph The heterogeneous graph
h : tensor h : tensor
Input features Input features
......
...@@ -34,7 +34,7 @@ class HANLayer(torch.nn.Module): ...@@ -34,7 +34,7 @@ class HANLayer(torch.nn.Module):
Inputs Inputs
------ ------
g : DGLHeteroGraph g : DGLGraph
The heterogeneous graph The heterogeneous graph
h : tensor h : tensor
Input features Input features
......
...@@ -469,7 +469,7 @@ def doc_subgraph(G, doc_ids): ...@@ -469,7 +469,7 @@ def doc_subgraph(G, doc_ids):
_, _, (block,) = sampler.sample( _, _, (block,) = sampler.sample(
G.reverse(), {"doc": torch.as_tensor(doc_ids)} G.reverse(), {"doc": torch.as_tensor(doc_ids)}
) )
B = dgl.DGLHeteroGraph( B = dgl.DGLGraph(
block._graph, ["_", "word", "doc", "_"], block.etypes block._graph, ["_", "word", "doc", "_"], block.etypes
).reverse() ).reverse()
B.nodes["word"].data["_ID"] = block.nodes["word"].data["_ID"] B.nodes["word"].data["_ID"] = block.nodes["word"].data["_ID"]
......
...@@ -113,7 +113,7 @@ class RelGraphConvLayer(nn.Module): ...@@ -113,7 +113,7 @@ class RelGraphConvLayer(nn.Module):
""" """
Parameters Parameters
---------- ----------
g : DGLHeteroGraph g : DGLGraph
Input graph. Input graph.
inputs : dict[str, torch.Tensor] inputs : dict[str, torch.Tensor]
Node feature for each node type. Node feature for each node type.
......
...@@ -136,7 +136,7 @@ class WeightedSAGEConv(nn.Module): ...@@ -136,7 +136,7 @@ class WeightedSAGEConv(nn.Module):
class SAGENet(nn.Module): class SAGENet(nn.Module):
def __init__(self, hidden_dims, n_layers): def __init__(self, hidden_dims, n_layers):
""" """
g : DGLHeteroGraph g : DGLGraph
The user-item interaction graph. The user-item interaction graph.
This is only for finding the range of categorical variables. This is only for finding the range of categorical variables.
item_textsets : torchtext.data.Dataset item_textsets : torchtext.data.Dataset
......
...@@ -147,7 +147,7 @@ def assign_textual_node_features(ndata, textset, ntype): ...@@ -147,7 +147,7 @@ def assign_textual_node_features(ndata, textset, ntype):
The length would be stored as another node feature with name The length would be stored as another node feature with name
``field_name + '__len'``. ``field_name + '__len'``.
block : DGLHeteroGraph block : DGLGraph
First element of the compacted blocks, with "dgl.NID" as the First element of the compacted blocks, with "dgl.NID" as the
corresponding node ID in the original graph, hence the index to the corresponding node ID in the original graph, hence the index to the
text dataset. text dataset.
......
...@@ -101,7 +101,7 @@ class RelGraphConvLayer(nn.Module): ...@@ -101,7 +101,7 @@ class RelGraphConvLayer(nn.Module):
Parameters Parameters
---------- ----------
g : DGLHeteroGraph g : DGLGraph
Input graph. Input graph.
inputs : dict[str, torch.Tensor] inputs : dict[str, torch.Tensor]
Node feature for each node type. Node feature for each node type.
...@@ -224,7 +224,7 @@ class RelGraphConvLayerHeteroAPI(nn.Module): ...@@ -224,7 +224,7 @@ class RelGraphConvLayerHeteroAPI(nn.Module):
Parameters Parameters
---------- ----------
g : DGLHeteroGraph g : DGLGraph
Input graph. Input graph.
inputs : dict[str, torch.Tensor] inputs : dict[str, torch.Tensor]
Node feature for each node type. Node feature for each node type.
...@@ -302,14 +302,14 @@ class RelGraphEmbed(nn.Module): ...@@ -302,14 +302,14 @@ class RelGraphEmbed(nn.Module):
Parameters Parameters
---------- ----------
block : DGLHeteroGraph, optional block : DGLGraph, optional
If not specified, directly return the full graph with embeddings stored in If not specified, directly return the full graph with embeddings stored in
:attr:`embed_name`. Otherwise, extract and store the embeddings to the block :attr:`embed_name`. Otherwise, extract and store the embeddings to the block
graph and return. graph and return.
Returns Returns
------- -------
DGLHeteroGraph DGLGraph
The block graph fed with embeddings. The block graph fed with embeddings.
""" """
return self.embeds return self.embeds
......
...@@ -105,7 +105,7 @@ class RelGraphConvLayer(nn.Module): ...@@ -105,7 +105,7 @@ class RelGraphConvLayer(nn.Module):
"""Forward computation """Forward computation
Parameters Parameters
---------- ----------
g : DGLHeteroGraph g : DGLGraph
Input graph. Input graph.
inputs : dict[str, torch.Tensor] inputs : dict[str, torch.Tensor]
Node feature for each node type. Node feature for each node type.
......
...@@ -36,8 +36,8 @@ from .readout import * ...@@ -36,8 +36,8 @@ from .readout import *
from .batch import * from .batch import *
from .convert import * from .convert import *
from .generators import * from .generators import *
from .heterograph import DGLHeteroGraph from .heterograph import DGLGraph
from .heterograph import DGLHeteroGraph as DGLGraph # pylint: disable=reimported from .heterograph import DGLGraph as DGLHeteroGraph # pylint: disable=reimported
from .dataloading import set_src_lazy_features, set_dst_lazy_features, set_edge_lazy_features, \ from .dataloading import set_src_lazy_features, set_dst_lazy_features, set_edge_lazy_features, \
set_node_lazy_features set_node_lazy_features
from .merge import * from .merge import *
......
...@@ -10,7 +10,7 @@ from .. import backend as F ...@@ -10,7 +10,7 @@ from .. import backend as F
from .. import utils from .. import utils
from ..batch import batch from ..batch import batch
from ..convert import heterograph from ..convert import heterograph
from ..heterograph import DGLHeteroGraph as DGLGraph from ..heterograph import DGLGraph
from ..distributed.dist_graph import DistGraph from ..distributed.dist_graph import DistGraph
from ..utils import to_device from ..utils import to_device
......
...@@ -40,7 +40,7 @@ class DGLBaseGraph(object): ...@@ -40,7 +40,7 @@ class DGLBaseGraph(object):
Data to initialize graph. Data to initialize graph.
""" """
is_block = False # for compatibility with DGLHeteroGraph is_block = False # for compatibility with DGLGraph
def __init__(self, graph): def __init__(self, graph):
self._graph = graph self._graph = graph
......
...@@ -4,12 +4,12 @@ from collections.abc import Mapping ...@@ -4,12 +4,12 @@ from collections.abc import Mapping
from . import backend as F from . import backend as F
from .base import ALL, is_all, DGLError, dgl_warning, NID, EID from .base import ALL, is_all, DGLError, dgl_warning, NID, EID
from .heterograph_index import disjoint_union, slice_gidx from .heterograph_index import disjoint_union, slice_gidx
from .heterograph import DGLHeteroGraph from .heterograph import DGLGraph
from . import convert from . import convert
from . import utils from . import utils
__all__ = ['batch', 'unbatch', 'slice_batch', 'batch_hetero', 'unbatch_hetero'] __all__ = ['batch', 'unbatch', 'slice_batch']
def batch(graphs, ndata=ALL, edata=ALL, *, def batch(graphs, ndata=ALL, edata=ALL, *,
node_attrs=None, edge_attrs=None): node_attrs=None, edge_attrs=None):
...@@ -175,7 +175,7 @@ def batch(graphs, ndata=ALL, edata=ALL, *, ...@@ -175,7 +175,7 @@ def batch(graphs, ndata=ALL, edata=ALL, *,
etypes = [etype for _, etype, _ in relations] etypes = [etype for _, etype, _ in relations]
gidx = disjoint_union(graphs[0]._graph.metagraph, [g._graph for g in graphs]) gidx = disjoint_union(graphs[0]._graph.metagraph, [g._graph for g in graphs])
retg = DGLHeteroGraph(gidx, ntypes, etypes) retg = DGLGraph(gidx, ntypes, etypes)
# Compute batch num nodes # Compute batch num nodes
bnn = {} bnn = {}
...@@ -479,7 +479,7 @@ def slice_batch(g, gid, store_ids=False): ...@@ -479,7 +479,7 @@ def slice_batch(g, gid, store_ids=False):
# Slice graph structure # Slice graph structure
gidx = slice_gidx(g._graph, utils.toindex(num_nodes), utils.toindex(start_nid), gidx = slice_gidx(g._graph, utils.toindex(num_nodes), utils.toindex(start_nid),
utils.toindex(num_edges), utils.toindex(start_eid)) utils.toindex(num_edges), utils.toindex(start_eid))
retg = DGLHeteroGraph(gidx, g.ntypes, g.etypes) retg = DGLGraph(gidx, g.ntypes, g.etypes)
# Slice node features # Slice node features
for ntid, ntype in enumerate(g.ntypes): for ntid, ntype in enumerate(g.ntypes):
...@@ -504,16 +504,3 @@ def slice_batch(g, gid, store_ids=False): ...@@ -504,16 +504,3 @@ def slice_batch(g, gid, store_ids=False):
retg.idtype, retg.device) retg.idtype, retg.device)
return retg return retg
#### DEPRECATED APIS ####
def batch_hetero(*args, **kwargs):
"""DEPREACTED: please use dgl.batch """
dgl_warning('From v0.5, DGLHeteroGraph is merged into DGLGraph. You can safely'
' replace dgl.batch_hetero with dgl.batch')
return batch(*args, **kwargs)
def unbatch_hetero(*args, **kwargs):
"""DEPREACTED: please use dgl.unbatch """
dgl_warning('From v0.5, DGLHeteroGraph is merged into DGLGraph. You can safely'
' replace dgl.unbatch_hetero with dgl.unbatch')
return unbatch(*args, **kwargs)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment