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
7d87dcec
Unverified
Commit
7d87dcec
authored
Oct 11, 2023
by
Rhett Ying
Committed by
GitHub
Oct 11, 2023
Browse files
[GraphBolt][Doc] update impl (#6418)
parent
c1d117a6
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
41 additions
and
25 deletions
+41
-25
docs/source/api/python/dgl.graphbolt.rst
docs/source/api/python/dgl.graphbolt.rst
+0
-2
python/dgl/graphbolt/impl/basic_feature_store.py
python/dgl/graphbolt/impl/basic_feature_store.py
+1
-1
python/dgl/graphbolt/impl/csc_sampling_graph.py
python/dgl/graphbolt/impl/csc_sampling_graph.py
+12
-1
python/dgl/graphbolt/impl/neighbor_sampler.py
python/dgl/graphbolt/impl/neighbor_sampler.py
+7
-2
python/dgl/graphbolt/impl/ondisk_dataset.py
python/dgl/graphbolt/impl/ondisk_dataset.py
+9
-11
python/dgl/graphbolt/impl/sampled_subgraph_impl.py
python/dgl/graphbolt/impl/sampled_subgraph_impl.py
+3
-1
python/dgl/graphbolt/impl/torch_based_feature_store.py
python/dgl/graphbolt/impl/torch_based_feature_store.py
+2
-2
python/dgl/graphbolt/impl/uniform_negative_sampler.py
python/dgl/graphbolt/impl/uniform_negative_sampler.py
+7
-5
No files found.
docs/source/api/python/dgl.graphbolt.rst
View file @
7d87dcec
...
@@ -56,8 +56,6 @@ Standard Implementations
...
@@ -56,8 +56,6 @@ Standard Implementations
OnDiskDataset
OnDiskDataset
BuiltinDataset
BuiltinDataset
OnDiskTask
OnDiskMetaData
CSCSamplingGraph
CSCSamplingGraph
UniformNegativeSampler
UniformNegativeSampler
NeighborSampler
NeighborSampler
...
...
python/dgl/graphbolt/impl/basic_feature_store.py
View file @
7d87dcec
...
@@ -10,7 +10,7 @@ __all__ = ["BasicFeatureStore"]
...
@@ -10,7 +10,7 @@ __all__ = ["BasicFeatureStore"]
class
BasicFeatureStore
(
FeatureStore
):
class
BasicFeatureStore
(
FeatureStore
):
r
"""
B
asic feature store."""
r
"""
A b
asic feature store
to manage multiple features for access
."""
def
__init__
(
self
,
features
:
Dict
[
Tuple
[
str
,
str
,
str
],
Feature
]):
def
__init__
(
self
,
features
:
Dict
[
Tuple
[
str
,
str
,
str
],
Feature
]):
r
"""Initiate a basic feature store.
r
"""Initiate a basic feature store.
...
...
python/dgl/graphbolt/impl/csc_sampling_graph.py
View file @
7d87dcec
...
@@ -16,6 +16,17 @@ from ..sampling_graph import SamplingGraph
...
@@ -16,6 +16,17 @@ from ..sampling_graph import SamplingGraph
from
.sampled_subgraph_impl
import
SampledSubgraphImpl
from
.sampled_subgraph_impl
import
SampledSubgraphImpl
__all__
=
[
"GraphMetadata"
,
"CSCSamplingGraph"
,
"from_csc"
,
"load_from_shared_memory"
,
"load_csc_sampling_graph"
,
"save_csc_sampling_graph"
,
"from_dglgraph"
,
]
class
GraphMetadata
:
class
GraphMetadata
:
r
"""Class for metadata of csc sampling graph."""
r
"""Class for metadata of csc sampling graph."""
...
@@ -76,7 +87,7 @@ class GraphMetadata:
...
@@ -76,7 +87,7 @@ class GraphMetadata:
class
CSCSamplingGraph
(
SamplingGraph
):
class
CSCSamplingGraph
(
SamplingGraph
):
r
"""
Class for CSC
sampling graph."""
r
"""
A
sampling graph
in CSC format
."""
def
__repr__
(
self
):
def
__repr__
(
self
):
return
_csc_sampling_graph_str
(
self
)
return
_csc_sampling_graph_str
(
self
)
...
...
python/dgl/graphbolt/impl/neighbor_sampler.py
View file @
7d87dcec
...
@@ -8,9 +8,13 @@ from ..utils import unique_and_compact_node_pairs
...
@@ -8,9 +8,13 @@ from ..utils import unique_and_compact_node_pairs
from
.sampled_subgraph_impl
import
SampledSubgraphImpl
from
.sampled_subgraph_impl
import
SampledSubgraphImpl
__all__
=
[
"NeighborSampler"
,
"LayerNeighborSampler"
]
@
functional_datapipe
(
"sample_neighbor"
)
@
functional_datapipe
(
"sample_neighbor"
)
class
NeighborSampler
(
SubgraphSampler
):
class
NeighborSampler
(
SubgraphSampler
):
"""
"""Sample neighbor edges from a graph and return a subgraph.
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
...
@@ -121,7 +125,8 @@ class NeighborSampler(SubgraphSampler):
...
@@ -121,7 +125,8 @@ class NeighborSampler(SubgraphSampler):
@
functional_datapipe
(
"sample_layer_neighbor"
)
@
functional_datapipe
(
"sample_layer_neighbor"
)
class
LayerNeighborSampler
(
NeighborSampler
):
class
LayerNeighborSampler
(
NeighborSampler
):
"""
"""Sample layer neighbor edges from a graph and return a subgraph.
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/ondisk_dataset.py
View file @
7d87dcec
...
@@ -279,13 +279,13 @@ class OnDiskTask:
...
@@ -279,13 +279,13 @@ class OnDiskTask:
class
OnDiskDataset
(
Dataset
):
class
OnDiskDataset
(
Dataset
):
"""An on-disk dataset.
"""An on-disk dataset which reads graph topology, feature data and
Train/Validation/Test set from disk.
An on-disk dataset is a dataset which reads graph topology, feature data
Due to limited resources, the data which are too large to fit into RAM will
and TVT set from disk. Due to limited resources, the data which are too
remain on disk while others reside in RAM once ``OnDiskDataset`` is
large to fit into RAM will remain on disk while others reside in RAM once
initialized. This behavior could be controled by user via ``in_memory``
``OnDiskDataset`` is initialized. This behavior could be controled by user
field in YAML file.
via ``in_memory`` field in YAML file.
A full example of YAML file is as follows:
A full example of YAML file is as follows:
...
@@ -477,12 +477,10 @@ class OnDiskDataset(Dataset):
...
@@ -477,12 +477,10 @@ class OnDiskDataset(Dataset):
class
BuiltinDataset
(
OnDiskDataset
):
class
BuiltinDataset
(
OnDiskDataset
):
"""GraphBolt builtin on-disk dataset.
"""A utility class to download built-in dataset from AWS S3 and load it as
``OnDiskDataset``.
This class is used to help download datasets from DGL S3 storage and load
Available built-in datasets include:
them as ``OnDiskDataset``.
Available builtin datasets include:
**ogbn-mag**
**ogbn-mag**
The ogbn-mag dataset is a heterogeneous network composed of a subset of
The ogbn-mag dataset is a heterogeneous network composed of a subset of
...
...
python/dgl/graphbolt/impl/sampled_subgraph_impl.py
View file @
7d87dcec
...
@@ -8,10 +8,12 @@ import torch
...
@@ -8,10 +8,12 @@ import torch
from
..base
import
etype_str_to_tuple
from
..base
import
etype_str_to_tuple
from
..sampled_subgraph
import
SampledSubgraph
from
..sampled_subgraph
import
SampledSubgraph
__all__
=
[
"SampledSubgraphImpl"
]
@
dataclass
@
dataclass
class
SampledSubgraphImpl
(
SampledSubgraph
):
class
SampledSubgraphImpl
(
SampledSubgraph
):
r
"""
Class for s
ampled subgraph
specific for
CSCSamplingGraph.
r
"""
S
ampled subgraph
of
CSCSamplingGraph.
Examples
Examples
--------
--------
...
...
python/dgl/graphbolt/impl/torch_based_feature_store.py
View file @
7d87dcec
...
@@ -12,7 +12,7 @@ __all__ = ["TorchBasedFeature", "TorchBasedFeatureStore"]
...
@@ -12,7 +12,7 @@ __all__ = ["TorchBasedFeature", "TorchBasedFeatureStore"]
class
TorchBasedFeature
(
Feature
):
class
TorchBasedFeature
(
Feature
):
r
"""
T
orch based feature."""
r
"""
A wrapper of pyt
orch based feature."""
def
__init__
(
self
,
torch_feature
:
torch
.
Tensor
):
def
__init__
(
self
,
torch_feature
:
torch
.
Tensor
):
"""Initialize a torch based feature store by a torch feature.
"""Initialize a torch based feature store by a torch feature.
...
@@ -130,7 +130,7 @@ class TorchBasedFeature(Feature):
...
@@ -130,7 +130,7 @@ class TorchBasedFeature(Feature):
class
TorchBasedFeatureStore
(
BasicFeatureStore
):
class
TorchBasedFeatureStore
(
BasicFeatureStore
):
r
"""
T
orch based feature
store
."""
r
"""
A store to manage multiple pyt
orch based feature
for access
."""
def
__init__
(
self
,
feat_data
:
List
[
OnDiskFeatureData
]):
def
__init__
(
self
,
feat_data
:
List
[
OnDiskFeatureData
]):
r
"""Load feature stores from disk.
r
"""Load feature stores from disk.
...
...
python/dgl/graphbolt/impl/uniform_negative_sampler.py
View file @
7d87dcec
...
@@ -4,14 +4,16 @@ from torch.utils.data import functional_datapipe
...
@@ -4,14 +4,16 @@ from torch.utils.data import functional_datapipe
from
..negative_sampler
import
NegativeSampler
from
..negative_sampler
import
NegativeSampler
__all__
=
[
"UniformNegativeSampler"
]
@
functional_datapipe
(
"sample_uniform_negative"
)
@
functional_datapipe
(
"sample_uniform_negative"
)
class
UniformNegativeSampler
(
NegativeSampler
):
class
UniformNegativeSampler
(
NegativeSampler
):
"""
"""
Sample negative destination nodes for each source node based on a uniform
Negative samplers randomly select negative destination nodes for each
distribution.
source node based on a uniform distribution. It's important to note that
the term 'negative' refers to false negatives,
indicating that the sampled
It's important to note that
the term 'negative' refers to false negatives,
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
of negative edges ``(u, v')``, where ``v'`` is chosen uniformly from all
of negative edges ``(u, v')``, where ``v'`` is chosen uniformly from all
the nodes in the graph.
the nodes in the graph.
...
...
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