Skip to content

Commit

Permalink
fix batchsampler does not work correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
yyh committed Oct 9, 2024
1 parent 8ad3e29 commit 0fd3e8a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lightning/pytorch/utilities/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,14 @@ def _is_dataloader_shuffled(dataloader: object) -> bool:
if not hasattr(dataloader, "sampler"):
# shuffling is enabled via a sampler. No sampler, no shuffling
return False
sampler = dataloader.sampler

batch_sampler = dataloader.batch_sampler
if batch_sampler is not None:
# batchsize == 1 case:
sampler = batch_sampler.sampler
else:
sampler = dataloader.sampler

if isinstance(sampler, SequentialSampler):
return False
return isinstance(sampler, RandomSampler)

0 comments on commit 0fd3e8a

Please sign in to comment.