spdl.dataloader.CacheDataLoader¶
- class CacheDataLoader(dl: Iterable[T], num_caches: int, return_caches_after: int, stop_after: int | None = None)[source]¶
Caches values from the given data loader and returns caches after the given iteration.
The class is a simple wrapper around generic data loader instance. It is intended for estimating the maximum performance gain achieved by optimizing the data loader.
You can wrap your data loader with this class, and run it in the training pipeline, and compare the performance to see if the training pipeline is bottlenecked with data loading.
- Parameters:
dl – Source iterator. Expected to be a data loader object.
num_caches – See
spdl.pipeline.cache_iterator()
.return_caches_after – See
spdl.pipeline.cache_iterator()
.stop_after – See
spdl.pipeline.cache_iterator()
.
- Returns:
The new iterator.
See also
spdl.pipeline.cache_iterator()
: The helper function that implements the caching logic.
- __iter__() Iterator[T] [source]¶
See
spdl.pipeline.cache_iterator()
for the detail.