Shortcuts

Attention

June 2024 Status Update: Removing DataPipes and DataLoader V2

We are re-focusing the torchdata repo to be an iterative enhancement of torch.utils.data.DataLoader. We do not plan on continuing development or maintaining the [DataPipes] and [DataLoaderV2] solutions, and they will be removed from the torchdata repo. We’ll also be revisiting the DataPipes references in pytorch/pytorch. In release torchdata==0.8.0 (July 2024) they will be marked as deprecated, and in 0.9.0 (Oct 2024) they will be deleted. Existing users are advised to pin to torchdata==0.8.0 or an older version until they are able to migrate away. Subsequent releases will not include DataPipes or DataLoaderV2. Please reach out if you suggestions or comments (please use this issue for feedback)

Repeater

class torchdata.datapipes.iter.Repeater(source_datapipe: IterDataPipe[T_co], times: int)

Repeatedly yield each element of source DataPipe for the specified number of times before moving onto the next element (functional name: repeat). Note that no copy is made in this DataPipe, the same element is yielded repeatedly.

If you would like to yield the whole DataPipe in order multiple times, use Cycler.

Parameters:
  • source_datapipe – source DataPipe that will be iterated through

  • times – the number of times an element of source_datapipe will be yielded before moving onto the next element

Example

>>> from torchdata.datapipes.iter import IterableWrapper
>>> dp = IterableWrapper(range(3))
>>> dp = dp.repeat(2)
>>> list(dp)
[0, 0, 1, 1, 2, 2]

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources