Skip to content

Commit

Permalink
run precommit
Browse files Browse the repository at this point in the history
  • Loading branch information
ramanishsingh committed Feb 7, 2025
1 parent 1346e44 commit 4de1bb4
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 166 deletions.
11 changes: 4 additions & 7 deletions torchdata/stateful_dataloader/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,15 @@ def load_state_dict(self, state_dict: Dict[str, Any]) -> None:
assert isinstance(self.sampler_iter, Stateful)
self.sampler_iter.load_state_dict(state_dict[self._SAMPLER_ITER_STATE])

if not (
isinstance(self.sampler, Stateful)
or isinstance(self.sampler_iter, Stateful)
) and not isinstance(self.sampler, _InfiniteConstantSampler):
if not (isinstance(self.sampler, Stateful) or isinstance(self.sampler_iter, Stateful)) and not isinstance(
self.sampler, _InfiniteConstantSampler
):
# We skip x samples if underlying sampler is not stateful
for _ in range(self.samples_yielded):
next(self.sampler_iter)

def update_state_dict(self) -> None:
if isinstance(self.sampler_iter, Stateful) and hasattr(
self.sampler_iter, "update_state_dict"
):
if isinstance(self.sampler_iter, Stateful) and hasattr(self.sampler_iter, "update_state_dict"):
self.sampler_iter.update_state_dict()


Expand Down
Loading

0 comments on commit 4de1bb4

Please sign in to comment.