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)
| 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. |