Skip to content

Commit

Permalink
increase prefetch factor
Browse files Browse the repository at this point in the history
  • Loading branch information
fschlatt committed Aug 15, 2024
1 parent 04b36ce commit 95789cb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lightning_ir/data/datamodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,18 @@ def train_dataloader(self) -> DataLoader:
num_workers=self.num_workers,
collate_fn=self.collate_fn,
shuffle=(False if isinstance(self.train_dataset, IterableDataset) else self.shuffle_train),
prefetch_factor=16 if self.num_workers > 0 else None,
)

def inference_dataloader(self) -> List[DataLoader]:
inference_datasets = self.inference_datasets or []
return [
DataLoader(
dataset, batch_size=self.inference_batch_size, num_workers=self.num_workers, collate_fn=self.collate_fn
dataset,
batch_size=self.inference_batch_size,
num_workers=self.num_workers,
collate_fn=self.collate_fn,
prefetch_factor=16 if self.num_workers > 0 else None,
)
for dataset in inference_datasets
]
Expand Down

0 comments on commit 95789cb

Please sign in to comment.