Unverified Commit 7d87dcec authored by Rhett Ying's avatar Rhett Ying Committed by GitHub
Browse files

[GraphBolt][Doc] update impl (#6418)

parent c1d117a6
...@@ -56,8 +56,6 @@ Standard Implementations ...@@ -56,8 +56,6 @@ Standard Implementations
OnDiskDataset OnDiskDataset
BuiltinDataset BuiltinDataset
OnDiskTask
OnDiskMetaData
CSCSamplingGraph CSCSamplingGraph
UniformNegativeSampler UniformNegativeSampler
NeighborSampler NeighborSampler
......
...@@ -10,7 +10,7 @@ __all__ = ["BasicFeatureStore"] ...@@ -10,7 +10,7 @@ __all__ = ["BasicFeatureStore"]
class BasicFeatureStore(FeatureStore): class BasicFeatureStore(FeatureStore):
r"""Basic feature store.""" r"""A basic 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.
......
...@@ -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)
......
...@@ -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
......
...@@ -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
......
...@@ -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 sampled subgraph specific for CSCSamplingGraph. r"""Sampled subgraph of CSCSamplingGraph.
Examples Examples
-------- --------
......
...@@ -12,7 +12,7 @@ __all__ = ["TorchBasedFeature", "TorchBasedFeatureStore"] ...@@ -12,7 +12,7 @@ __all__ = ["TorchBasedFeature", "TorchBasedFeatureStore"]
class TorchBasedFeature(Feature): class TorchBasedFeature(Feature):
r"""Torch based feature.""" r"""A wrapper of pytorch 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"""Torch based feature store.""" r"""A store to manage multiple pytorch 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.
......
...@@ -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.
......
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