"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "f57e7bd92c57bf59cba45496fc85ea77797bedcc"
Unverified Commit ab0c0ec6 authored by peizhou001's avatar peizhou001 Committed by GitHub
Browse files

[API Deprecation] Deprecate candidates in convert module (#4988) (#5115)

parent 46a3fc2b
...@@ -10,20 +10,16 @@ from . import heterograph_index ...@@ -10,20 +10,16 @@ from . import heterograph_index
from .heterograph import DGLGraph, combine_frames, DGLBlock from .heterograph import DGLGraph, combine_frames, DGLBlock
from . import graph_index from . import graph_index
from . import utils from . import utils
from .base import NTYPE, ETYPE, NID, EID, DGLError, dgl_warning from .base import NTYPE, ETYPE, NID, EID, DGLError
__all__ = [ __all__ = [
'graph', 'graph',
'bipartite',
'hetero_from_relations',
'hetero_from_shared_memory', 'hetero_from_shared_memory',
'heterograph', 'heterograph',
'create_block', 'create_block',
'block_to_graph', 'block_to_graph',
'to_heterogeneous', 'to_heterogeneous',
'to_hetero',
'to_homogeneous', 'to_homogeneous',
'to_homo',
'from_scipy', 'from_scipy',
'bipartite_from_scipy', 'bipartite_from_scipy',
'from_networkx', 'from_networkx',
...@@ -34,14 +30,12 @@ __all__ = [ ...@@ -34,14 +30,12 @@ __all__ = [
] ]
def graph(data, def graph(data,
ntype=None, etype=None,
*, *,
num_nodes=None, num_nodes=None,
idtype=None, idtype=None,
device=None, device=None,
row_sorted=False, row_sorted=False,
col_sorted=False, col_sorted=False):
**deprecated_kwargs):
"""Create a graph and return. """Create a graph and return.
Parameters Parameters
...@@ -67,10 +61,6 @@ def graph(data, ...@@ -67,10 +61,6 @@ def graph(data,
The tensors can be replaced with any iterable of integers (e.g. list, tuple, The tensors can be replaced with any iterable of integers (e.g. list, tuple,
numpy.ndarray). numpy.ndarray).
ntype : str, optional
Deprecated. To construct a graph with named node types, use :func:`dgl.heterograph`.
etype : str, optional
Deprecated. To construct a graph with named edge types, use :func:`dgl.heterograph`.
num_nodes : int, optional num_nodes : int, optional
The number of nodes in the graph. If not given, this will be the largest node ID The number of nodes in the graph. If not given, this will be the largest node ID
plus 1 from the :attr:`data` argument. If given and the value is no greater than plus 1 from the :attr:`data` argument. If given and the value is no greater than
...@@ -156,14 +146,6 @@ def graph(data, ...@@ -156,14 +146,6 @@ def graph(data,
from_scipy from_scipy
from_networkx from_networkx
""" """
# Deprecated arguments
if ntype is not None:
raise DGLError('The ntype argument is deprecated for dgl.graph. To construct ' \
'a graph with named node types, use dgl.heterograph.')
if etype is not None:
raise DGLError('The etype argument is deprecated for dgl.graph. To construct ' \
'a graph with named edge types, use dgl.heterograph.')
if isinstance(data, spmatrix): if isinstance(data, spmatrix):
raise DGLError("dgl.graph no longer supports graph construction from a SciPy " raise DGLError("dgl.graph no longer supports graph construction from a SciPy "
"sparse matrix, use dgl.from_scipy instead.") "sparse matrix, use dgl.from_scipy instead.")
...@@ -172,12 +154,6 @@ def graph(data, ...@@ -172,12 +154,6 @@ def graph(data,
raise DGLError("dgl.graph no longer supports graph construction from a NetworkX " raise DGLError("dgl.graph no longer supports graph construction from a NetworkX "
"graph, use dgl.from_networkx instead.") "graph, use dgl.from_networkx instead.")
if len(deprecated_kwargs) != 0:
raise DGLError("Key word arguments {} have been removed from dgl.graph()."
" They are moved to dgl.from_scipy() and dgl.from_networkx()."
" Please refer to their API documents for more details.".format(
deprecated_kwargs.keys()))
(sparse_fmt, arrays), urange, vrange = utils.graphdata2tensors(data, idtype) (sparse_fmt, arrays), urange, vrange = utils.graphdata2tensors(data, idtype)
if num_nodes is not None: # override the number of nodes if num_nodes is not None: # override the number of nodes
if num_nodes < max(urange, vrange): if num_nodes < max(urange, vrange):
...@@ -190,24 +166,6 @@ def graph(data, ...@@ -190,24 +166,6 @@ def graph(data,
return g.to(device) return g.to(device)
def bipartite(data,
utype='_U', etype='_E', vtype='_V',
num_nodes=None,
card=None,
validate=True,
restrict_format='any',
**kwargs):
"""DEPRECATED: use dgl.heterograph instead."""
raise DGLError(
'dgl.bipartite is deprecated. Use dgl.heterograph({' +
"('{}', '{}', '{}')".format(utype, etype, vtype) +
' : data} to create a bipartite graph instead.')
def hetero_from_relations(rel_graphs, num_nodes_per_type=None):
"""DEPRECATED: use dgl.heterograph instead."""
raise DGLError('dgl.hetero_from_relations is deprecated.\n\n'
'Use dgl.heterograph instead.')
def hetero_from_shared_memory(name): def hetero_from_shared_memory(name):
"""Create a heterograph from shared memory with the given name. """Create a heterograph from shared memory with the given name.
...@@ -826,16 +784,6 @@ def to_heterogeneous(G, ntypes, etypes, ntype_field=NTYPE, ...@@ -826,16 +784,6 @@ def to_heterogeneous(G, ntypes, etypes, ntype_field=NTYPE,
return hg return hg
def to_hetero(G, ntypes, etypes, ntype_field=NTYPE, etype_field=ETYPE,
metagraph=None):
"""Convert the given homogeneous graph to a heterogeneous graph.
DEPRECATED: Please use to_heterogeneous
"""
dgl_warning("dgl.to_hetero is deprecated. Please use dgl.to_heterogeneous")
return to_heterogeneous(G, ntypes, etypes, ntype_field=ntype_field,
etype_field=etype_field, metagraph=metagraph)
def to_homogeneous(G, ndata=None, edata=None, store_type=True, return_count=False): def to_homogeneous(G, ndata=None, edata=None, store_type=True, return_count=False):
"""Convert a heterogeneous graph to a homogeneous graph and return. """Convert a heterogeneous graph to a homogeneous graph and return.
...@@ -991,14 +939,6 @@ def to_homogeneous(G, ndata=None, edata=None, store_type=True, return_count=Fals ...@@ -991,14 +939,6 @@ def to_homogeneous(G, ndata=None, edata=None, store_type=True, return_count=Fals
else: else:
return retg return retg
def to_homo(G):
"""Convert the given heterogeneous graph to a homogeneous graph.
DEPRECATED: Please use to_homogeneous
"""
dgl_warning("dgl.to_homo is deprecated. Please use dgl.to_homogeneous")
return to_homogeneous(G)
def from_scipy(sp_mat, def from_scipy(sp_mat,
eweight_name=None, eweight_name=None,
idtype=None, idtype=None,
......
...@@ -652,7 +652,9 @@ class DistGraph: ...@@ -652,7 +652,9 @@ class DistGraph:
-------- --------
The following example uses PyTorch backend. The following example uses PyTorch backend.
>>> g = dgl.bipartite(([0, 1, 1, 2], [0, 0, 2, 1]), 'user', 'plays', 'game') >>> g = dgl.heterograph({
... ('user', 'plays', 'game'): ([0, 1, 1, 2], [0, 0, 2, 1])
... })
>>> print(g.device) >>> print(g.device)
device(type='cpu') device(type='cpu')
>>> g = g.to('cuda:0') >>> g = g.to('cuda:0')
......
...@@ -93,7 +93,7 @@ class GMMConv(nn.Block): ...@@ -93,7 +93,7 @@ class GMMConv(nn.Block):
>>> # Case 2: Unidirectional bipartite graph >>> # Case 2: Unidirectional bipartite graph
>>> u = [0, 1, 0, 0, 1] >>> u = [0, 1, 0, 0, 1]
>>> v = [0, 1, 2, 3, 2] >>> v = [0, 1, 2, 3, 2]
>>> g = dgl.bipartite((u, v)) >>> g = dgl.heterograph({('_N', '_E', '_N'):(u, v)})
>>> u_fea = mx.nd.random.randn(2, 5) >>> u_fea = mx.nd.random.randn(2, 5)
>>> v_fea = mx.nd.random.randn(4, 10) >>> v_fea = mx.nd.random.randn(4, 10)
>>> pseudo = mx.nd.ones((5, 3)) >>> pseudo = mx.nd.ones((5, 3))
......
...@@ -120,7 +120,7 @@ class GraphConv(gluon.Block): ...@@ -120,7 +120,7 @@ class GraphConv(gluon.Block):
>>> # Case 2: Unidirectional bipartite graph >>> # Case 2: Unidirectional bipartite graph
>>> u = [0, 1, 0, 0, 1] >>> u = [0, 1, 0, 0, 1]
>>> v = [0, 1, 2, 3, 2] >>> v = [0, 1, 2, 3, 2]
>>> g = dgl.bipartite((u, v)) >>> g = dgl.heterograph({('_N', '_E', '_N'):(u, v)})
>>> u_fea = mx.nd.random.randn(2, 5) >>> u_fea = mx.nd.random.randn(2, 5)
>>> v_fea = mx.nd.random.randn(4, 5) >>> v_fea = mx.nd.random.randn(4, 5)
>>> conv = GraphConv(5, 2, norm='both', weight=True, bias=True) >>> conv = GraphConv(5, 2, norm='both', weight=True, bias=True)
......
...@@ -75,7 +75,7 @@ class NNConv(nn.Block): ...@@ -75,7 +75,7 @@ class NNConv(nn.Block):
>>> # Case 2: Unidirectional bipartite graph >>> # Case 2: Unidirectional bipartite graph
>>> u = [0, 1, 0, 0, 1] >>> u = [0, 1, 0, 0, 1]
>>> v = [0, 1, 2, 3, 2] >>> v = [0, 1, 2, 3, 2]
>>> g = dgl.bipartite((u, v)) >>> g = dgl.heterograph({('_N', '_E', '_N'):(u, v)})
>>> u_feat = mx.nd.random.randn(2, 10) >>> u_feat = mx.nd.random.randn(2, 10)
>>> v_feat = mx.nd.random.randn(4, 10) >>> v_feat = mx.nd.random.randn(4, 10)
>>> conv = NNConv(10, 2, edge_func, 'mean') >>> conv = NNConv(10, 2, edge_func, 'mean')
......
...@@ -76,7 +76,7 @@ class SAGEConv(nn.Block): ...@@ -76,7 +76,7 @@ class SAGEConv(nn.Block):
>>> # Case 2: Unidirectional bipartite graph >>> # Case 2: Unidirectional bipartite graph
>>> u = [0, 1, 0, 0, 1] >>> u = [0, 1, 0, 0, 1]
>>> v = [0, 1, 2, 3, 2] >>> v = [0, 1, 2, 3, 2]
>>> g = dgl.bipartite((u, v)) >>> g = dgl.heterograph({('_N', '_E', '_N'):(u, v)})
>>> u_fea = mx.nd.random.randn(2, 5) >>> u_fea = mx.nd.random.randn(2, 5)
>>> v_fea = mx.nd.random.randn(4, 10) >>> v_fea = mx.nd.random.randn(4, 10)
>>> conv = SAGEConv((5, 10), 2, 'pool') >>> conv = SAGEConv((5, 10), 2, 'pool')
......
...@@ -99,7 +99,7 @@ class DotGatConv(nn.Module): ...@@ -99,7 +99,7 @@ class DotGatConv(nn.Module):
>>> # Case 2: Unidirectional bipartite graph >>> # Case 2: Unidirectional bipartite graph
>>> u = [0, 1, 0, 0, 1] >>> u = [0, 1, 0, 0, 1]
>>> v = [0, 1, 2, 3, 2] >>> v = [0, 1, 2, 3, 2]
>>> g = dgl.bipartite((u, v)) >>> g = dgl.heterograph({('_N', '_E', '_N'):(u, v)})
>>> u_feat = th.tensor(np.random.rand(2, 5).astype(np.float32)) >>> u_feat = th.tensor(np.random.rand(2, 5).astype(np.float32))
>>> v_feat = th.tensor(np.random.rand(4, 10).astype(np.float32)) >>> v_feat = th.tensor(np.random.rand(4, 10).astype(np.float32))
>>> dotgatconv = DotGatConv((5,10), 2, 3) >>> dotgatconv = DotGatConv((5,10), 2, 3)
......
...@@ -81,7 +81,7 @@ class EdgeConv(nn.Module): ...@@ -81,7 +81,7 @@ class EdgeConv(nn.Module):
>>> # Case 2: Unidirectional bipartite graph >>> # Case 2: Unidirectional bipartite graph
>>> u = [0, 1, 0, 0, 1] >>> u = [0, 1, 0, 0, 1]
>>> v = [0, 1, 2, 3, 2] >>> v = [0, 1, 2, 3, 2]
>>> g = dgl.bipartite((u, v)) >>> g = dgl.heterograph({('_N', '_E', '_N'):(u, v)})
>>> u_fea = th.rand(2, 5) >>> u_fea = th.rand(2, 5)
>>> v_fea = th.rand(4, 5) >>> v_fea = th.rand(4, 5)
>>> conv = EdgeConv(5, 2, 3) >>> conv = EdgeConv(5, 2, 3)
......
...@@ -91,7 +91,7 @@ class GMMConv(nn.Module): ...@@ -91,7 +91,7 @@ class GMMConv(nn.Module):
>>> # Case 2: Unidirectional bipartite graph >>> # Case 2: Unidirectional bipartite graph
>>> u = [0, 1, 0, 0, 1] >>> u = [0, 1, 0, 0, 1]
>>> v = [0, 1, 2, 3, 2] >>> v = [0, 1, 2, 3, 2]
>>> g = dgl.bipartite((u, v)) >>> g = dgl.heterograph({('_N', '_E', '_N'):(u, v)})
>>> u_fea = th.rand(2, 5) >>> u_fea = th.rand(2, 5)
>>> v_fea = th.rand(4, 10) >>> v_fea = th.rand(4, 10)
>>> pseudo = th.ones(5, 3) >>> pseudo = th.ones(5, 3)
......
...@@ -72,7 +72,7 @@ class NNConv(nn.Module): ...@@ -72,7 +72,7 @@ class NNConv(nn.Module):
>>> # Case 2: Unidirectional bipartite graph >>> # Case 2: Unidirectional bipartite graph
>>> u = [0, 1, 0, 0, 1] >>> u = [0, 1, 0, 0, 1]
>>> v = [0, 1, 2, 3, 2] >>> v = [0, 1, 2, 3, 2]
>>> g = dgl.bipartite((u, v)) >>> g = dgl.heterograph({('_N', '_E', '_N'):(u, v)})
>>> u_feat = th.tensor(np.random.rand(2, 10).astype(np.float32)) >>> u_feat = th.tensor(np.random.rand(2, 10).astype(np.float32))
>>> v_feat = th.tensor(np.random.rand(4, 10).astype(np.float32)) >>> v_feat = th.tensor(np.random.rand(4, 10).astype(np.float32))
>>> conv = NNConv(10, 2, edge_func, 'mean') >>> conv = NNConv(10, 2, edge_func, 'mean')
......
...@@ -83,7 +83,7 @@ class SAGEConv(nn.Module): ...@@ -83,7 +83,7 @@ class SAGEConv(nn.Module):
>>> # Case 2: Unidirectional bipartite graph >>> # Case 2: Unidirectional bipartite graph
>>> u = [0, 1, 0, 0, 1] >>> u = [0, 1, 0, 0, 1]
>>> v = [0, 1, 2, 3, 2] >>> v = [0, 1, 2, 3, 2]
>>> g = dgl.bipartite((u, v)) >>> g = dgl.heterograph({('_N', '_E', '_N'):(u, v)})
>>> u_fea = th.rand(2, 5) >>> u_fea = th.rand(2, 5)
>>> v_fea = th.rand(4, 10) >>> v_fea = th.rand(4, 10)
>>> conv = SAGEConv((5, 10), 2, 'mean') >>> conv = SAGEConv((5, 10), 2, 'mean')
......
...@@ -122,7 +122,7 @@ class GraphConv(layers.Layer): ...@@ -122,7 +122,7 @@ class GraphConv(layers.Layer):
>>> u = [0, 1, 0, 0, 1] >>> u = [0, 1, 0, 0, 1]
>>> v = [0, 1, 2, 3, 2] >>> v = [0, 1, 2, 3, 2]
>>> with tf.device("CPU:0"): >>> with tf.device("CPU:0"):
... g = dgl.bipartite((u, v)) ... g = dgl.heterograph({('_N', '_E', '_N'):(u, v)})
... u_fea = tf.convert_to_tensor(np.random.rand(2, 5)) ... u_fea = tf.convert_to_tensor(np.random.rand(2, 5))
... v_fea = tf.convert_to_tensor(np.random.rand(4, 5)) ... v_fea = tf.convert_to_tensor(np.random.rand(4, 5))
... conv = GraphConv(5, 2, norm='both', weight=True, bias=True) ... conv = GraphConv(5, 2, norm='both', weight=True, bias=True)
......
...@@ -76,7 +76,7 @@ class SAGEConv(layers.Layer): ...@@ -76,7 +76,7 @@ class SAGEConv(layers.Layer):
>>> with tf.device("CPU:0"): >>> with tf.device("CPU:0"):
>>> u = [0, 1, 0, 0, 1] >>> u = [0, 1, 0, 0, 1]
>>> v = [0, 1, 2, 3, 2] >>> v = [0, 1, 2, 3, 2]
>>> g = dgl.bipartite((u, v)) >>> g = dgl.heterograph({('_N', '_E', '_N'):(u, v)})
>>> u_fea = tf.convert_to_tensor(np.random.rand(2, 5)) >>> u_fea = tf.convert_to_tensor(np.random.rand(2, 5))
>>> v_fea = tf.convert_to_tensor(np.random.rand(4, 5)) >>> v_fea = tf.convert_to_tensor(np.random.rand(4, 5))
>>> conv = SAGEConv((5, 10), 2, 'mean') >>> conv = SAGEConv((5, 10), 2, 'mean')
......
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