(self, indices, device, pin_memory=False, **kwargs)
| 29 | """Feature storages for slicing a PyTorch tensor.""" |
| 30 | |
| 31 | def fetch(self, indices, device, pin_memory=False, **kwargs): |
| 32 | device = torch.device(device) |
| 33 | storage_device_type = self.storage.device.type |
| 34 | indices_device_type = indices.device.type |
| 35 | if storage_device_type != "cuda": |
| 36 | if indices_device_type == "cuda": |
| 37 | if self.storage.is_pinned(): |
| 38 | return gather_pinned_tensor_rows(self.storage, indices) |
| 39 | else: |
| 40 | raise ValueError( |
| 41 | f"Got indices on device {indices.device} whereas the feature tensor " |
| 42 | f"is on {self.storage.device}. Please either (1) move the graph " |
| 43 | f"to GPU with to() method, or (2) pin the graph with " |
| 44 | f"pin_memory_() method." |
| 45 | ) |
| 46 | # CPU to CPU or CUDA - use pin_memory and async transfer if possible |
| 47 | else: |
| 48 | return _fetch_cpu( |
| 49 | indices, |
| 50 | self.storage, |
| 51 | self.storage.shape[1:], |
| 52 | device, |
| 53 | pin_memory, |
| 54 | **kwargs, |
| 55 | ) |
| 56 | else: |
| 57 | # CUDA to CUDA or CPU |
| 58 | return _fetch_cuda(indices, self.storage, device, **kwargs) |
nothing calls this directly
no test coverage detected