Read the tensor at ``self.prefix + sep + name``. Empty ``name`` reads the tensor at the exact prefix. Raises ``KeyError`` on miss (delegates to checkpoint). If ``index`` is not None, the checkpoint slices the tensor along dim 0 on CPU before transferring to GPU.
(self, name: str = '', sep: str = '.', *, index=None)
| 61 | # ----- tensor access ----- |
| 62 | |
| 63 | def get(self, name: str = '', sep: str = '.', *, index=None) -> torch.Tensor: |
| 64 | """Read the tensor at ``self.prefix + sep + name``. |
| 65 | |
| 66 | Empty ``name`` reads the tensor at the exact prefix. Raises |
| 67 | ``KeyError`` on miss (delegates to checkpoint). |
| 68 | |
| 69 | If ``index`` is not None, the checkpoint slices the tensor along |
| 70 | dim 0 on CPU before transferring to GPU. |
| 71 | """ |
| 72 | return self.ckpt.get(self._joined(name, sep), index=index) |
| 73 | |
| 74 | def has(self, name: str = '', sep: str = '.') -> bool: |
| 75 | return self.ckpt.has(self._joined(name, sep)) |