Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dgl
Commits
3132da28
Unverified
Commit
3132da28
authored
Nov 15, 2022
by
peizhou001
Committed by
GitHub
Nov 15, 2022
Browse files
Deprecate (#4864)
rename DGLHeteroGraph to DGLGraph
parent
ee9887d6
Changes
45
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
35 additions
and
50 deletions
+35
-50
benchmarks/benchmarks/model_speed/bench_pinsage.py
benchmarks/benchmarks/model_speed/bench_pinsage.py
+2
-2
benchmarks/benchmarks/model_speed/bench_rgcn_hetero_ns.py
benchmarks/benchmarks/model_speed/bench_rgcn_hetero_ns.py
+3
-3
docs/source/api/python/dgl.rst
docs/source/api/python/dgl.rst
+0
-2
examples/pytorch/GATNE-T/src/main.py
examples/pytorch/GATNE-T/src/main.py
+1
-1
examples/pytorch/GATNE-T/src/main_sparse.py
examples/pytorch/GATNE-T/src/main_sparse.py
+1
-1
examples/pytorch/GATNE-T/src/main_sparse_multi_gpus.py
examples/pytorch/GATNE-T/src/main_sparse_multi_gpus.py
+1
-1
examples/pytorch/gcmc/data.py
examples/pytorch/gcmc/data.py
+6
-6
examples/pytorch/gcmc/model.py
examples/pytorch/gcmc/model.py
+2
-2
examples/pytorch/han/model_hetero.py
examples/pytorch/han/model_hetero.py
+1
-1
examples/pytorch/han/train_sampling.py
examples/pytorch/han/train_sampling.py
+1
-1
examples/pytorch/lda/lda_model.py
examples/pytorch/lda/lda_model.py
+1
-1
examples/pytorch/ogb/ogbn-mag/hetero_rgcn.py
examples/pytorch/ogb/ogbn-mag/hetero_rgcn.py
+1
-1
examples/pytorch/pinsage/layers.py
examples/pytorch/pinsage/layers.py
+1
-1
examples/pytorch/pinsage/sampler.py
examples/pytorch/pinsage/sampler.py
+1
-1
examples/pytorch/rgcn-hetero/model.py
examples/pytorch/rgcn-hetero/model.py
+4
-4
examples/pytorch/rgcn/experimental/entity_classify_dist.py
examples/pytorch/rgcn/experimental/entity_classify_dist.py
+1
-1
python/dgl/__init__.py
python/dgl/__init__.py
+2
-2
python/dgl/_dataloading/dataloader.py
python/dgl/_dataloading/dataloader.py
+1
-1
python/dgl/_deprecate/graph.py
python/dgl/_deprecate/graph.py
+1
-1
python/dgl/batch.py
python/dgl/batch.py
+4
-17
No files found.
benchmarks/benchmarks/model_speed/bench_pinsage.py
View file @
3132da28
...
@@ -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 : DGL
Hetero
Graph
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 : DGL
Hetero
Graph
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.
...
...
benchmarks/benchmarks/model_speed/bench_rgcn_hetero_ns.py
View file @
3132da28
...
@@ -88,7 +88,7 @@ class RelGraphConvLayer(nn.Module):
...
@@ -88,7 +88,7 @@ class RelGraphConvLayer(nn.Module):
Parameters
Parameters
----------
----------
g : DGL
Hetero
Graph
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 : DGL
Hetero
Graph, 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
-------
-------
DGL
Hetero
Graph
DGLGraph
The block graph fed with embeddings.
The block graph fed with embeddings.
"""
"""
embeds
=
{}
embeds
=
{}
...
...
docs/source/api/python/dgl.rst
View file @
3132da28
...
@@ -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
...
...
examples/pytorch/GATNE-T/src/main.py
View file @
3132da28
...
@@ -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
------
------
DGL
Hetero
Graph
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
=
[]
...
...
examples/pytorch/GATNE-T/src/main_sparse.py
View file @
3132da28
...
@@ -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
------
------
DGL
Hetero
Graph
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
=
[]
...
...
examples/pytorch/GATNE-T/src/main_sparse_multi_gpus.py
View file @
3132da28
...
@@ -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
------
------
DGL
Hetero
Graph
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
=
[]
...
...
examples/pytorch/gcmc/data.py
View file @
3132da28
...
@@ -46,25 +46,25 @@ class MovieLens(object):
...
@@ -46,25 +46,25 @@ class MovieLens(object):
Attributes
Attributes
----------
----------
train_enc_graph : dgl.DGL
Hetero
Graph
train_enc_graph : dgl.DGLGraph
Encoder graph for training.
Encoder graph for training.
train_dec_graph : dgl.DGL
Hetero
Graph
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.DGL
Hetero
Graph
valid_enc_graph : dgl.DGLGraph
Encoder graph for validation.
Encoder graph for validation.
valid_dec_graph : dgl.DGL
Hetero
Graph
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.DGL
Hetero
Graph
test_enc_graph : dgl.DGLGraph
Encoder graph for test.
Encoder graph for test.
test_dec_graph : dgl.DGL
Hetero
Graph
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
...
...
examples/pytorch/gcmc/model.py
View file @
3132da28
...
@@ -233,7 +233,7 @@ class GCMCLayer(nn.Module):
...
@@ -233,7 +233,7 @@ class GCMCLayer(nn.Module):
Parameters
Parameters
----------
----------
graph : DGL
Hetero
Graph
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 : DGL
Hetero
Graph
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)
...
...
examples/pytorch/han/model_hetero.py
View file @
3132da28
...
@@ -47,7 +47,7 @@ class HANLayer(nn.Module):
...
@@ -47,7 +47,7 @@ class HANLayer(nn.Module):
Inputs
Inputs
------
------
g : DGL
Hetero
Graph
g : DGLGraph
The heterogeneous graph
The heterogeneous graph
h : tensor
h : tensor
Input features
Input features
...
...
examples/pytorch/han/train_sampling.py
View file @
3132da28
...
@@ -34,7 +34,7 @@ class HANLayer(torch.nn.Module):
...
@@ -34,7 +34,7 @@ class HANLayer(torch.nn.Module):
Inputs
Inputs
------
------
g : DGL
Hetero
Graph
g : DGLGraph
The heterogeneous graph
The heterogeneous graph
h : tensor
h : tensor
Input features
Input features
...
...
examples/pytorch/lda/lda_model.py
View file @
3132da28
...
@@ -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
.
DGL
Hetero
Graph
(
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"
]
...
...
examples/pytorch/ogb/ogbn-mag/hetero_rgcn.py
View file @
3132da28
...
@@ -113,7 +113,7 @@ class RelGraphConvLayer(nn.Module):
...
@@ -113,7 +113,7 @@ class RelGraphConvLayer(nn.Module):
"""
"""
Parameters
Parameters
----------
----------
g : DGL
Hetero
Graph
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.
...
...
examples/pytorch/pinsage/layers.py
View file @
3132da28
...
@@ -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 : DGL
Hetero
Graph
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
...
...
examples/pytorch/pinsage/sampler.py
View file @
3132da28
...
@@ -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 : DGL
Hetero
Graph
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.
...
...
examples/pytorch/rgcn-hetero/model.py
View file @
3132da28
...
@@ -101,7 +101,7 @@ class RelGraphConvLayer(nn.Module):
...
@@ -101,7 +101,7 @@ class RelGraphConvLayer(nn.Module):
Parameters
Parameters
----------
----------
g : DGL
Hetero
Graph
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 : DGL
Hetero
Graph
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 : DGL
Hetero
Graph, 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
-------
-------
DGL
Hetero
Graph
DGLGraph
The block graph fed with embeddings.
The block graph fed with embeddings.
"""
"""
return
self
.
embeds
return
self
.
embeds
...
...
examples/pytorch/rgcn/experimental/entity_classify_dist.py
View file @
3132da28
...
@@ -105,7 +105,7 @@ class RelGraphConvLayer(nn.Module):
...
@@ -105,7 +105,7 @@ class RelGraphConvLayer(nn.Module):
"""Forward computation
"""Forward computation
Parameters
Parameters
----------
----------
g : DGL
Hetero
Graph
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.
...
...
python/dgl/__init__.py
View file @
3132da28
...
@@ -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
DGL
Hetero
Graph
from
.heterograph
import
DGLGraph
from
.heterograph
import
DGL
Hetero
Graph
as
DGLGraph
# pylint: disable=reimported
from
.heterograph
import
DGLGraph
as
DGL
Hetero
Graph
# 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
*
...
...
python/dgl/_dataloading/dataloader.py
View file @
3132da28
...
@@ -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
...
...
python/dgl/_deprecate/graph.py
View file @
3132da28
...
@@ -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 DGL
Hetero
Graph
is_block
=
False
# for compatibility with DGLGraph
def
__init__
(
self
,
graph
):
def
__init__
(
self
,
graph
):
self
.
_graph
=
graph
self
.
_graph
=
graph
...
...
python/dgl/batch.py
View file @
3132da28
...
@@ -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
DGL
Hetero
Graph
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
=
DGL
Hetero
Graph
(
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
=
DGL
Hetero
Graph
(
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
)
Prev
1
2
3
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment