MCPcopy
hub / github.com/dmlc/dgl / read

Method read

python/dgl/graphbolt/impl/torch_based_feature_store.py:402–423  ·  view source on GitHub ↗

Read the feature by index. The returned tensor will be on CPU. Parameters ---------- ids : torch.Tensor The index of the feature. Only the specified indices of the feature are read. Returns ------- torch.Tensor

(self, ids: torch.Tensor = None)

Source from the content-addressed store, hash-verified

400 )
401
402 def read(self, ids: torch.Tensor = None):
403 """Read the feature by index.
404 The returned tensor will be on CPU.
405 Parameters
406 ----------
407 ids : torch.Tensor
408 The index of the feature. Only the specified indices of the
409 feature are read.
410 Returns
411 -------
412 torch.Tensor
413 The read feature.
414 """
415 if ids is None:
416 return self._tensor
417 elif torch.ops.graphbolt.detect_io_uring():
418 try:
419 return self._ondisk_npy_array.index_select(ids).wait()
420 except RuntimeError:
421 raise IndexError
422 else:
423 return index_select(self._tensor, ids)
424
425 def read_async(self, ids: torch.Tensor):
426 r"""Read the feature by index asynchronously.

Callers 2

test_disk_based_featureFunction · 0.95

Calls 3

index_selectFunction · 0.85
index_selectMethod · 0.80
waitMethod · 0.45

Tested by 2

test_disk_based_featureFunction · 0.76