MCPcopy Create free account
hub / github.com/awslabs/gap-text2sql / __init__

Method __init__

relogic/pretrainkit/trainer.py:98–111  ·  view source on GitHub ↗
(self, dataset, num_replicas=None, rank=None)

Source from the content-addressed store, hash-verified

96 """
97
98 def __init__(self, dataset, num_replicas=None, rank=None):
99 if num_replicas is None:
100 if not torch.distributed.is_available():
101 raise RuntimeError("Requires distributed package to be available")
102 num_replicas = torch.distributed.get_world_size()
103 if rank is None:
104 if not torch.distributed.is_available():
105 raise RuntimeError("Requires distributed package to be available")
106 rank = torch.distributed.get_rank()
107 self.dataset = dataset
108 self.num_replicas = num_replicas
109 self.rank = rank
110 self.num_samples = int(math.ceil(len(self.dataset) * 1.0 / self.num_replicas))
111 self.total_size = self.num_samples * self.num_replicas
112
113 def __iter__(self):
114 indices = list(range(len(self.dataset)))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected