IterableWrapper¶
- class torchdata.datapipes.iter.IterableWrapper(iterable, deepcopy=True)¶
Wraps an iterable object to create an IterDataPipe.
- Parameters:
iterable – Iterable object to be wrapped into an IterDataPipe
deepcopy – Option to deepcopy input iterable object for each iterator. The copy is made when the first element is read in
iter()
.
Note
If
deepcopy
is explicitly set toFalse
, users should ensure that the data pipeline doesn’t contain any in-place operations over the iterable instance to prevent data inconsistency across iterations.Example
>>> # xdoctest: +SKIP >>> from torchdata.datapipes.iter import IterableWrapper >>> dp = IterableWrapper(range(10)) >>> list(dp) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]