Shortcuts

MapToIterConverter

class torchdata.datapipes.iter.MapToIterConverter(datapipe: MapDataPipe, indices: Optional[List] = None)

Convert a MapDataPipe to an IterDataPipe (functional name: to_iter_datapipe). It uses indices to iterate through the MapDataPipe, defaults to range(len(mapdatapipe)) if not given.

For the opposite converter, use IterToMapConverter.

Parameters:
  • datapipe – source MapDataPipe with data

  • indices – optional list of indices that will dictate how the datapipe will be iterated over

Example

>>> from torchdata.datapipes.map import SequenceWrapper
>>> source_dp = SequenceWrapper(range(10))
>>> iter_dp = source_dp.to_iter_datapipe()
>>> list(iter_dp)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

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