"docs/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "914c513ee07026299614f30804e0e28bf079a459"
Unverified Commit f6fa920d authored by Rhett Ying's avatar Rhett Ying Committed by GitHub
Browse files

[GraphBolt] Add functional name into docstring (#6739)

parent 06dc1dc4
......@@ -104,6 +104,8 @@ class CopyTo(IterDataPipe):
"""DataPipe that transfers each element yielded from the previous DataPipe
to the given device.
Functional name: :obj:`copy_to`.
This is equivalent to
.. code:: python
......
......@@ -16,7 +16,30 @@ __all__ = [
@functional_datapipe("fetch_feature")
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__(
self,
......@@ -25,29 +48,6 @@ class FeatureFetcher(MiniBatchTransformer):
node_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)
self.feature_store = feature_store
self.node_feature_keys = node_feature_keys
......
......@@ -15,6 +15,8 @@ __all__ = ["InSubgraphSampler"]
class InSubgraphSampler(SubgraphSampler):
"""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,
returning an induced subgraph along with compacted information.
......
......@@ -20,6 +20,8 @@ __all__ = ["NeighborSampler", "LayerNeighborSampler"]
class NeighborSampler(SubgraphSampler):
"""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
returns an induced subgraph along with compacted information. In the
context of a node classification task, the neighbor sampler directly
......@@ -183,6 +185,8 @@ class NeighborSampler(SubgraphSampler):
class LayerNeighborSampler(NeighborSampler):
"""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
labor sampling for multilayer GNN from the NeurIPS 2023 paper
`Layer-Neighbor Sampling -- Defusing Neighborhood Explosion in GNNs
......
......@@ -12,6 +12,8 @@ class UniformNegativeSampler(NegativeSampler):
"""Sample negative destination nodes for each source node based on a uniform
distribution.
Functional name: :obj:`sample_uniform_negative`.
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.
For each edge ``(u, v)``, it is supposed to generate `negative_ratio` pairs
......
......@@ -14,23 +14,24 @@ __all__ = [
@functional_datapipe("transform")
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__(
self,
datapipe,
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)
self.transformer = transformer
......@@ -44,17 +45,18 @@ class MiniBatchTransformer(Mapper):
@functional_datapipe("to_dgl")
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__(
self,
datapipe,
):
"""
Initlization for a subgraph transformer.
Parameters
----------
datapipe : DataPipe
The datapipe.
"""
super().__init__(datapipe, MiniBatch.to_dgl)
......@@ -16,6 +16,15 @@ class NegativeSampler(MiniBatchTransformer):
"""
A negative sampler used to generate negative samples and return
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__(
......@@ -23,16 +32,6 @@ class NegativeSampler(MiniBatchTransformer):
datapipe,
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)
assert negative_ratio > 0, "Negative_ratio should be positive Integer."
self.negative_ratio = negative_ratio
......
......@@ -17,20 +17,20 @@ __all__ = [
@functional_datapipe("sample_subgraph")
class SubgraphSampler(MiniBatchTransformer):
"""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__(
self,
datapipe,
):
"""
Initlization for a subgraph sampler.
Parameters
----------
datapipe : DataPipe
The datapipe.
"""
super().__init__(datapipe, self._sample)
def _sample(self, minibatch):
......
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