MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / RepeatingLoader

Class RepeatingLoader

deepspeed/runtime/dataloader.py:17–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15
16
17class RepeatingLoader:
18
19 def __init__(self, loader):
20 """Wraps an iterator to allow for infinite iteration. This is especially useful
21 for DataLoader types that we wish to automatically restart upon completion.
22
23 Args:
24 loader (iterator): The data loader to repeat.
25 """
26 self.loader = loader
27 self.data_iter = iter(self.loader)
28
29 def __iter__(self):
30 return self
31
32 def __next__(self):
33 try:
34 batch = next(self.data_iter)
35 except StopIteration:
36 self.data_iter = iter(self.loader)
37 batch = next(self.data_iter)
38 return batch
39
40
41class DeepSpeedDataLoader(object):

Callers 8

testMethod · 0.85
testMethod · 0.85
test_pp_basicMethod · 0.85
runMethod · 0.85
_testMethod · 0.85
test_repeating_loaderFunction · 0.85
_build_data_iterMethod · 0.85

Calls

no outgoing calls

Tested by 7

testMethod · 0.68
testMethod · 0.68
test_pp_basicMethod · 0.68
runMethod · 0.68
_testMethod · 0.68
test_repeating_loaderFunction · 0.68