MCPcopy Index your code
hub / github.com/dmlc/dgl / read

Method read

python/dgl/graphbolt/impl/cpu_cached_feature.py:52–70  ·  view source on GitHub ↗

Read the feature by index. Parameters ---------- ids : torch.Tensor, optional The index of the feature. If specified, only the specified indices of the feature are read. If None, the entire feature is returned. Returns -------

(self, ids: torch.Tensor = None)

Source from the content-addressed store, hash-verified

50 self._offset = offset
51
52 def read(self, ids: torch.Tensor = None):
53 """Read the feature by index.
54
55 Parameters
56 ----------
57 ids : torch.Tensor, optional
58 The index of the feature. If specified, only the specified indices
59 of the feature are read. If None, the entire feature is returned.
60
61 Returns
62 -------
63 torch.Tensor
64 The read feature.
65 """
66 if ids is None:
67 return self._fallback_feature.read()
68 return self._feature.query_and_replace(
69 ids.cpu(), self._fallback_feature.read, self._offset
70 ).to(ids.device)
71
72 def read_async(self, ids: torch.Tensor):
73 r"""Read the feature by index asynchronously.

Callers 1

calculate_file_hashFunction · 0.45

Calls 3

query_and_replaceMethod · 0.80
toMethod · 0.45
cpuMethod · 0.45

Tested by

no test coverage detected