r"""Initialize a ShardedTensorLoader. Args: target (``torch.Tensor``): The target tensor where value shards are loaded into. num_shards (int): Number of expected shards. shard_dim (int): The dimension along which the tensor is sharded.
(
self,
target: torch.Tensor,
num_shards: int,
shard_dim: int,
mode: str = "set",
)
| 531 | """ |
| 532 | |
| 533 | def __init__( |
| 534 | self, |
| 535 | target: torch.Tensor, |
| 536 | num_shards: int, |
| 537 | shard_dim: int, |
| 538 | mode: str = "set", |
| 539 | ) -> None: |
| 540 | r"""Initialize a ShardedTensorLoader. |
| 541 | |
| 542 | Args: |
| 543 | target (``torch.Tensor``): The target tensor where value shards are |
| 544 | loaded into. |
| 545 | num_shards (int): Number of expected shards. |
| 546 | shard_dim (int): The dimension along which the tensor is sharded. |
| 547 | mode (str): Supported options are ``set`` and ``add``. If ``set``, |
| 548 | the old value in the target tensor is overrided with the new |
| 549 | value. If ``add``, the new value is added to the old value. |
| 550 | """ |
| 551 | self._target = target |
| 552 | self._num_shards = num_shards |
| 553 | self._shard_dim = shard_dim |
| 554 | self._mode = mode |
| 555 | |
| 556 | self._loaded_shards = set() |
| 557 | |
| 558 | def load_shard(self, shard_id: int, value: torch.Tensor) -> None: |
| 559 | r"""Load a shard into the target tensor. |
nothing calls this directly
no outgoing calls
no test coverage detected