Skip to content

Commit 0fd3e8a

Browse files
author
yyh
committed
fix batchsampler does not work correctly
1 parent 8ad3e29 commit 0fd3e8a

File tree

1 file changed

+8
-1
lines changed
  • src/lightning/pytorch/utilities

1 file changed

+8
-1
lines changed

src/lightning/pytorch/utilities/data.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,14 @@ def _is_dataloader_shuffled(dataloader: object) -> bool:
349349
if not hasattr(dataloader, "sampler"):
350350
# shuffling is enabled via a sampler. No sampler, no shuffling
351351
return False
352-
sampler = dataloader.sampler
352+
353+
batch_sampler = dataloader.batch_sampler
354+
if batch_sampler is not None:
355+
# batchsize == 1 case:
356+
sampler = batch_sampler.sampler
357+
else:
358+
sampler = dataloader.sampler
359+
353360
if isinstance(sampler, SequentialSampler):
354361
return False
355362
return isinstance(sampler, RandomSampler)

0 commit comments

Comments
 (0)