Unverified Commit 7a10bcb6 authored by Muhammed Fatih BALIN's avatar Muhammed Fatih BALIN Committed by GitHub
Browse files

[GraphBolt][Doc] Minor fixes and clarifications. (#7135)

parent 364cb718
...@@ -90,9 +90,9 @@ def expand_indptr(indptr, dtype=None, node_ids=None, output_size=None): ...@@ -90,9 +90,9 @@ def expand_indptr(indptr, dtype=None, node_ids=None, output_size=None):
argument avoids a stream synchronization to calculate the output shape. argument avoids a stream synchronization to calculate the output shape.
Returns Returns
------- -------
torch.Tensor torch.Tensor
The converted COO tensor with values from node_ids. The converted COO tensor with values from node_ids.
""" """
assert indptr.dim() == 1, "Indptr should be 1D tensor." assert indptr.dim() == 1, "Indptr should be 1D tensor."
assert not ( assert not (
...@@ -127,9 +127,9 @@ def index_select(tensor, index): ...@@ -127,9 +127,9 @@ def index_select(tensor, index):
The 1-D tensor containing the indices to index. The 1-D tensor containing the indices to index.
Returns Returns
------- -------
torch.Tensor torch.Tensor
The indexed input tensor, equivalent to tensor[index]. The indexed input tensor, equivalent to tensor[index].
""" """
assert index.dim() == 1, "Index should be 1D tensor." assert index.dim() == 1, "Index should be 1D tensor."
return torch.ops.graphbolt.index_select(tensor, index) return torch.ops.graphbolt.index_select(tensor, index)
......
...@@ -84,7 +84,9 @@ class DataLoader(torch.utils.data.DataLoader): ...@@ -84,7 +84,9 @@ class DataLoader(torch.utils.data.DataLoader):
everything after feature fetching in the main process. The datapipe everything after feature fetching in the main process. The datapipe
is modified in-place as a result. is modified in-place as a result.
Only works on single GPU. When the copy_to operation is placed earlier in the data pipeline, the
num_workers argument is required to be 0 as utilizing CUDA in multiple
worker processes is not supported.
Parameters Parameters
---------- ----------
......
...@@ -63,6 +63,7 @@ class TorchBasedFeature(Feature): ...@@ -63,6 +63,7 @@ class TorchBasedFeature(Feature):
tensor([[1, 2]]) tensor([[1, 2]])
3. Pinned CPU feature. 3. Pinned CPU feature.
>>> torch_feat = torch.arange(10).reshape(2, -1).pin_memory() >>> torch_feat = torch.arange(10).reshape(2, -1).pin_memory()
>>> feature = gb.TorchBasedFeature(torch_feat) >>> feature = gb.TorchBasedFeature(torch_feat)
>>> feature.read().device >>> feature.read().device
......
...@@ -32,11 +32,11 @@ def unique_and_compact( ...@@ -32,11 +32,11 @@ def unique_and_compact(
Returns Returns
------- -------
Tuple[unique_nodes, compacted_node_list] Tuple[unique_nodes, compacted_node_list]
The Unique nodes (per type) of all nodes in the input. And the compacted The Unique nodes (per type) of all nodes in the input. And the compacted
nodes list, where IDs inside are replaced with compacted node IDs. nodes list, where IDs inside are replaced with compacted node IDs.
"Compacted node list" indicates that the node IDs in the input node "Compacted node list" indicates that the node IDs in the input node
list are replaced with mapped node IDs, where each type of node is list are replaced with mapped node IDs, where each type of node is
mapped to a contiguous space of IDs ranging from 0 to N. mapped to a contiguous space of IDs ranging from 0 to N.
""" """
is_heterogeneous = isinstance(nodes, dict) is_heterogeneous = isinstance(nodes, dict)
......
...@@ -36,6 +36,7 @@ class ItemSet: ...@@ -36,6 +36,7 @@ class ItemSet:
>>> from dgl import graphbolt as gb >>> from dgl import graphbolt as gb
1. Integer: number of nodes. 1. Integer: number of nodes.
>>> num = 10 >>> num = 10
>>> item_set = gb.ItemSet(num, names="seed_nodes") >>> item_set = gb.ItemSet(num, names="seed_nodes")
>>> list(item_set) >>> list(item_set)
...@@ -47,6 +48,7 @@ class ItemSet: ...@@ -47,6 +48,7 @@ class ItemSet:
('seed_nodes',) ('seed_nodes',)
2. Single iterable: seed nodes. 2. Single iterable: seed nodes.
>>> node_ids = torch.arange(0, 5) >>> node_ids = torch.arange(0, 5)
>>> item_set = gb.ItemSet(node_ids, names="seed_nodes") >>> item_set = gb.ItemSet(node_ids, names="seed_nodes")
>>> list(item_set) >>> list(item_set)
...@@ -57,6 +59,7 @@ class ItemSet: ...@@ -57,6 +59,7 @@ class ItemSet:
('seed_nodes',) ('seed_nodes',)
3. Tuple of iterables with same shape: seed nodes and labels. 3. Tuple of iterables with same shape: seed nodes and labels.
>>> node_ids = torch.arange(0, 5) >>> node_ids = torch.arange(0, 5)
>>> labels = torch.arange(5, 10) >>> labels = torch.arange(5, 10)
>>> item_set = gb.ItemSet( >>> item_set = gb.ItemSet(
...@@ -70,6 +73,7 @@ class ItemSet: ...@@ -70,6 +73,7 @@ class ItemSet:
('seed_nodes', 'labels') ('seed_nodes', 'labels')
4. Tuple of iterables with different shape: node pairs and negative dsts. 4. Tuple of iterables with different shape: node pairs and negative dsts.
>>> node_pairs = torch.arange(0, 10).reshape(-1, 2) >>> node_pairs = torch.arange(0, 10).reshape(-1, 2)
>>> neg_dsts = torch.arange(10, 25).reshape(-1, 3) >>> neg_dsts = torch.arange(10, 25).reshape(-1, 3)
>>> item_set = gb.ItemSet( >>> item_set = gb.ItemSet(
......
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