data
data copied to clipboard
DataLoader2 should reset when a new iterator is created?
When a new iterator is created, DataLoader2
currently resumes from when it was left off rather than resetting and starting from the beginning again (see code snippet below). This is divergent from the behavior of the original DataLoader
. Users likely expect the latter behavior and we should properly reset the state of DataLoader2
when a new iterator is created.
from torchdata.dataloader2 import DataLoader2
from torchdata.datapipes.iter import IterableWrapper
dl = DataLoader2(IterableWrapper(range(10)))
for i in iter(dl):
print(i)
if i == 4:
print('--------------')
break
for i in iter(dl):
print(i)
cc: @VitalyFedyunin