MCPcopy Create free account
hub / github.com/hpcaitech/ColossalAI / DummyDataloader

Class DummyDataloader

examples/tutorial/hybrid_parallel/train.py:17–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16
17class DummyDataloader:
18 def __init__(self, length, batch_size):
19 self.length = length
20 self.batch_size = batch_size
21
22 def generate(self):
23 data = torch.rand(self.batch_size, 3, 224, 224)
24 label = torch.randint(low=0, high=10, size=(self.batch_size,))
25 return data, label
26
27 def __iter__(self):
28 self.step = 0
29 return self
30
31 def __next__(self):
32 if self.step < self.length:
33 self.step += 1
34 return self.generate()
35 else:
36 raise StopIteration
37
38 def __len__(self):
39 return self.length
40
41
42def main():

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…