Args: size (int): the total number of data of the underlying dataset to sample from
(self, size: int)
| 11 | """ |
| 12 | |
| 13 | def __init__(self, size: int): |
| 14 | """ |
| 15 | Args: |
| 16 | size (int): the total number of data of the underlying dataset to sample from |
| 17 | """ |
| 18 | self._size = size |
| 19 | assert size > 0 |
| 20 | self._rank = comm.get_rank() |
| 21 | self._world_size = comm.get_world_size() |
| 22 | |
| 23 | shard_size = (self._size - 1) // self._world_size + 1 |
| 24 | begin = shard_size * self._rank |
| 25 | end = min(shard_size * (self._rank + 1), self._size) |
| 26 | self._local_indices = range(begin, end) |
| 27 | |
| 28 | def __iter__(self): |
| 29 | while True: |
nothing calls this directly
no outgoing calls
no test coverage detected