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
f6fa920d
Unverified
Commit
f6fa920d
authored
Dec 13, 2023
by
Rhett Ying
Committed by
GitHub
Dec 13, 2023
Browse files
[GraphBolt] Add functional name into docstring (#6739)
parent
06dc1dc4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
73 additions
and
62 deletions
+73
-62
python/dgl/graphbolt/base.py
python/dgl/graphbolt/base.py
+2
-0
python/dgl/graphbolt/feature_fetcher.py
python/dgl/graphbolt/feature_fetcher.py
+24
-24
python/dgl/graphbolt/impl/in_subgraph_sampler.py
python/dgl/graphbolt/impl/in_subgraph_sampler.py
+2
-0
python/dgl/graphbolt/impl/neighbor_sampler.py
python/dgl/graphbolt/impl/neighbor_sampler.py
+4
-0
python/dgl/graphbolt/impl/uniform_negative_sampler.py
python/dgl/graphbolt/impl/uniform_negative_sampler.py
+2
-0
python/dgl/graphbolt/minibatch_transformer.py
python/dgl/graphbolt/minibatch_transformer.py
+21
-19
python/dgl/graphbolt/negative_sampler.py
python/dgl/graphbolt/negative_sampler.py
+9
-10
python/dgl/graphbolt/subgraph_sampler.py
python/dgl/graphbolt/subgraph_sampler.py
+9
-9
No files found.
python/dgl/graphbolt/base.py
View file @
f6fa920d
...
@@ -104,6 +104,8 @@ class CopyTo(IterDataPipe):
...
@@ -104,6 +104,8 @@ class CopyTo(IterDataPipe):
"""DataPipe that transfers each element yielded from the previous DataPipe
"""DataPipe that transfers each element yielded from the previous DataPipe
to the given device.
to the given device.
Functional name: :obj:`copy_to`.
This is equivalent to
This is equivalent to
.. code:: python
.. code:: python
...
...
python/dgl/graphbolt/feature_fetcher.py
View file @
f6fa920d
...
@@ -16,7 +16,30 @@ __all__ = [
...
@@ -16,7 +16,30 @@ __all__ = [
@
functional_datapipe
(
"fetch_feature"
)
@
functional_datapipe
(
"fetch_feature"
)
class
FeatureFetcher
(
MiniBatchTransformer
):
class
FeatureFetcher
(
MiniBatchTransformer
):
"""A feature fetcher used to fetch features for node/edge in graphbolt."""
"""A feature fetcher used to fetch features for node/edge in graphbolt.
Functional name: :obj:`fetch_feature`.
Parameters
----------
datapipe : DataPipe
The datapipe.
feature_store : FeatureStore
A storage for features, support read and update.
node_feature_keys : List[str] or Dict[str, List[str]]
Node features keys indicates the node features need to be read.
- If `node_features` is a list: It means the graph is homogeneous
graph, and the 'str' inside are feature names.
- If `node_features` is a dictionary: The keys should be node type
and the values are lists of feature names.
edge_feature_keys : List[str] or Dict[str, List[str]]
Edge features name indicates the edge features need to be read.
- If `edge_features` is a list: It means the graph is homogeneous
graph, and the 'str' inside are feature names.
- If `edge_features` is a dictionary: The keys are edge types,
following the format 'str:str:str', and the values are lists of
feature names.
"""
def
__init__
(
def
__init__
(
self
,
self
,
...
@@ -25,29 +48,6 @@ class FeatureFetcher(MiniBatchTransformer):
...
@@ -25,29 +48,6 @@ class FeatureFetcher(MiniBatchTransformer):
node_feature_keys
=
None
,
node_feature_keys
=
None
,
edge_feature_keys
=
None
,
edge_feature_keys
=
None
,
):
):
"""
Initlization for a feature fetcher.
Parameters
----------
datapipe : DataPipe
The datapipe.
feature_store : FeatureStore
A storage for features, support read and update.
node_feature_keys : List[str] or Dict[str, List[str]]
Node features keys indicates the node features need to be read.
- If `node_features` is a list: It means the graph is homogeneous
graph, and the 'str' inside are feature names.
- If `node_features` is a dictionary: The keys should be node type
and the values are lists of feature names.
edge_feature_keys : List[str] or Dict[str, List[str]]
Edge features name indicates the edge features need to be read.
- If `edge_features` is a list: It means the graph is homogeneous
graph, and the 'str' inside are feature names.
- If `edge_features` is a dictionary: The keys are edge types,
following the format 'str:str:str', and the values are lists of
feature names.
"""
super
().
__init__
(
datapipe
,
self
.
_read
)
super
().
__init__
(
datapipe
,
self
.
_read
)
self
.
feature_store
=
feature_store
self
.
feature_store
=
feature_store
self
.
node_feature_keys
=
node_feature_keys
self
.
node_feature_keys
=
node_feature_keys
...
...
python/dgl/graphbolt/impl/in_subgraph_sampler.py
View file @
f6fa920d
...
@@ -15,6 +15,8 @@ __all__ = ["InSubgraphSampler"]
...
@@ -15,6 +15,8 @@ __all__ = ["InSubgraphSampler"]
class
InSubgraphSampler
(
SubgraphSampler
):
class
InSubgraphSampler
(
SubgraphSampler
):
"""Sample the subgraph induced on the inbound edges of the given nodes.
"""Sample the subgraph induced on the inbound edges of the given nodes.
Functional name: :obj:`sample_in_subgraph`.
In-subgraph sampler is responsible for sampling a subgraph from given data,
In-subgraph sampler is responsible for sampling a subgraph from given data,
returning an induced subgraph along with compacted information.
returning an induced subgraph along with compacted information.
...
...
python/dgl/graphbolt/impl/neighbor_sampler.py
View file @
f6fa920d
...
@@ -20,6 +20,8 @@ __all__ = ["NeighborSampler", "LayerNeighborSampler"]
...
@@ -20,6 +20,8 @@ __all__ = ["NeighborSampler", "LayerNeighborSampler"]
class
NeighborSampler
(
SubgraphSampler
):
class
NeighborSampler
(
SubgraphSampler
):
"""Sample neighbor edges from a graph and return a subgraph.
"""Sample neighbor edges from a graph and return a subgraph.
Functional name: :obj:`sample_neighbor`.
Neighbor sampler is responsible for sampling a subgraph from given data. It
Neighbor sampler is responsible for sampling a subgraph from given data. It
returns an induced subgraph along with compacted information. In the
returns an induced subgraph along with compacted information. In the
context of a node classification task, the neighbor sampler directly
context of a node classification task, the neighbor sampler directly
...
@@ -183,6 +185,8 @@ class NeighborSampler(SubgraphSampler):
...
@@ -183,6 +185,8 @@ class NeighborSampler(SubgraphSampler):
class
LayerNeighborSampler
(
NeighborSampler
):
class
LayerNeighborSampler
(
NeighborSampler
):
"""Sample layer neighbor edges from a graph and return a subgraph.
"""Sample layer neighbor edges from a graph and return a subgraph.
Functional name: :obj:`sample_layer_neighbor`.
Sampler that builds computational dependency of node representations via
Sampler that builds computational dependency of node representations via
labor sampling for multilayer GNN from the NeurIPS 2023 paper
labor sampling for multilayer GNN from the NeurIPS 2023 paper
`Layer-Neighbor Sampling -- Defusing Neighborhood Explosion in GNNs
`Layer-Neighbor Sampling -- Defusing Neighborhood Explosion in GNNs
...
...
python/dgl/graphbolt/impl/uniform_negative_sampler.py
View file @
f6fa920d
...
@@ -12,6 +12,8 @@ class UniformNegativeSampler(NegativeSampler):
...
@@ -12,6 +12,8 @@ class UniformNegativeSampler(NegativeSampler):
"""Sample negative destination nodes for each source node based on a uniform
"""Sample negative destination nodes for each source node based on a uniform
distribution.
distribution.
Functional name: :obj:`sample_uniform_negative`.
It's important to note that the term 'negative' refers to false negatives,
It's important to note that the term 'negative' refers to false negatives,
indicating that the sampled pairs are not ensured to be absent in the graph.
indicating that the sampled pairs are not ensured to be absent in the graph.
For each edge ``(u, v)``, it is supposed to generate `negative_ratio` pairs
For each edge ``(u, v)``, it is supposed to generate `negative_ratio` pairs
...
...
python/dgl/graphbolt/minibatch_transformer.py
View file @
f6fa920d
...
@@ -14,23 +14,24 @@ __all__ = [
...
@@ -14,23 +14,24 @@ __all__ = [
@
functional_datapipe
(
"transform"
)
@
functional_datapipe
(
"transform"
)
class
MiniBatchTransformer
(
Mapper
):
class
MiniBatchTransformer
(
Mapper
):
"""A mini-batch transformer used to manipulate mini-batch"""
"""A mini-batch transformer used to manipulate mini-batch.
Functional name: :obj:`transform`.
Parameters
----------
datapipe : DataPipe
The datapipe.
transformer:
The function applied to each minibatch which is responsible for
transforming the minibatch.
"""
def
__init__
(
def
__init__
(
self
,
self
,
datapipe
,
datapipe
,
transformer
,
transformer
,
):
):
"""
Initlization for a subgraph transformer.
Parameters
----------
datapipe : DataPipe
The datapipe.
transformer:
The function applied to each minibatch which is responsible for
transforming the minibatch.
"""
super
().
__init__
(
datapipe
,
self
.
_transformer
)
super
().
__init__
(
datapipe
,
self
.
_transformer
)
self
.
transformer
=
transformer
self
.
transformer
=
transformer
...
@@ -44,17 +45,18 @@ class MiniBatchTransformer(Mapper):
...
@@ -44,17 +45,18 @@ class MiniBatchTransformer(Mapper):
@
functional_datapipe
(
"to_dgl"
)
@
functional_datapipe
(
"to_dgl"
)
class
DGLMiniBatchConverter
(
Mapper
):
class
DGLMiniBatchConverter
(
Mapper
):
"""Convert a graphbolt mini-batch to a dgl mini-batch."""
"""Convert a graphbolt mini-batch to a dgl mini-batch.
Functional name: :obj:`to_dgl`.
Parameters
----------
datapipe : DataPipe
The datapipe.
"""
def
__init__
(
def
__init__
(
self
,
self
,
datapipe
,
datapipe
,
):
):
"""
Initlization for a subgraph transformer.
Parameters
----------
datapipe : DataPipe
The datapipe.
"""
super
().
__init__
(
datapipe
,
MiniBatch
.
to_dgl
)
super
().
__init__
(
datapipe
,
MiniBatch
.
to_dgl
)
python/dgl/graphbolt/negative_sampler.py
View file @
f6fa920d
...
@@ -16,6 +16,15 @@ class NegativeSampler(MiniBatchTransformer):
...
@@ -16,6 +16,15 @@ class NegativeSampler(MiniBatchTransformer):
"""
"""
A negative sampler used to generate negative samples and return
A negative sampler used to generate negative samples and return
a mix of positive and negative samples.
a mix of positive and negative samples.
Functional name: :obj:`sample_negative`.
Parameters
----------
datapipe : DataPipe
The datapipe.
negative_ratio : int
The proportion of negative samples to positive samples.
"""
"""
def
__init__
(
def
__init__
(
...
@@ -23,16 +32,6 @@ class NegativeSampler(MiniBatchTransformer):
...
@@ -23,16 +32,6 @@ class NegativeSampler(MiniBatchTransformer):
datapipe
,
datapipe
,
negative_ratio
,
negative_ratio
,
):
):
"""
Initlization for a negative sampler.
Parameters
----------
datapipe : DataPipe
The datapipe.
negative_ratio : int
The proportion of negative samples to positive samples.
"""
super
().
__init__
(
datapipe
,
self
.
_sample
)
super
().
__init__
(
datapipe
,
self
.
_sample
)
assert
negative_ratio
>
0
,
"Negative_ratio should be positive Integer."
assert
negative_ratio
>
0
,
"Negative_ratio should be positive Integer."
self
.
negative_ratio
=
negative_ratio
self
.
negative_ratio
=
negative_ratio
...
...
python/dgl/graphbolt/subgraph_sampler.py
View file @
f6fa920d
...
@@ -17,20 +17,20 @@ __all__ = [
...
@@ -17,20 +17,20 @@ __all__ = [
@
functional_datapipe
(
"sample_subgraph"
)
@
functional_datapipe
(
"sample_subgraph"
)
class
SubgraphSampler
(
MiniBatchTransformer
):
class
SubgraphSampler
(
MiniBatchTransformer
):
"""A subgraph sampler used to sample a subgraph from a given set of nodes
"""A subgraph sampler used to sample a subgraph from a given set of nodes
from a larger graph."""
from a larger graph.
Functional name: :obj:`sample_subgraph`.
Parameters
----------
datapipe : DataPipe
The datapipe.
"""
def
__init__
(
def
__init__
(
self
,
self
,
datapipe
,
datapipe
,
):
):
"""
Initlization for a subgraph sampler.
Parameters
----------
datapipe : DataPipe
The datapipe.
"""
super
().
__init__
(
datapipe
,
self
.
_sample
)
super
().
__init__
(
datapipe
,
self
.
_sample
)
def
_sample
(
self
,
minibatch
):
def
_sample
(
self
,
minibatch
):
...
...
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