MCPcopy Create free account
hub / github.com/HYUNJS/SGT / __init__

Method __init__

projects/Datasets/MOT/distributed_sampler.py:13–26  ·  view source on GitHub ↗

Args: size (int): the total number of data of the underlying dataset to sample from

(self, size: int)

Source from the content-addressed store, hash-verified

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:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected