Skip to content

Commit d783247

Browse files
committed
only exhaust sampler_iter if present in sd
1 parent eb95deb commit d783247

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

torchdata/stateful_dataloader/stateful_dataloader.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -531,11 +531,11 @@ def load_state_dict(self, state_dict):
531531
self._sampler_iter = iter(self._index_sampler)
532532
if state_dict[_SAMPLER_ITER_STATE] is not None:
533533
self._sampler_iter = try_to_deserialize(self._sampler_iter, state_dict[_SAMPLER_ITER_STATE])
534-
if state_dict[_ITERATOR_FINISHED]:
535-
try:
536-
next(self._sampler_iter)
537-
except StopIteration:
538-
pass
534+
if state_dict[_ITERATOR_FINISHED]:
535+
try:
536+
next(self._sampler_iter)
537+
except StopIteration:
538+
pass
539539
else:
540540
if not isinstance(
541541
self._index_sampler,

0 commit comments

Comments
 (0)