MultiProcessingReadingService¶
- class torchdata.dataloader2.MultiProcessingReadingService(num_workers: int = 0, pin_memory: bool = False, timeout: float = 0, worker_init_fn: Callable[[int], None] | None = None, multiprocessing_context=None, prefetch_factor: int | None = None, persistent_workers: bool = False)¶
MultiProcessingReadingServicethat utilizestorch.utils.data.DataLoaderto launch subprocesses forDataPipegraph. Please refers to documents ofDataLoaderin https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader for all arguments.Note
This
ReadingServicebe replaced byPrototypeMultiProcessingReadingService.- finalize() None¶
ReadingServicecleans up internal states and fully shuts down the service. Called inDataLoader2’sshutdownand__del__.
- initialize(datapipe: IterDataPipe | MapDataPipe) IterDataPipe | MapDataPipe¶
ReadingServicetakes aDataPipegraph, adapts it into a newDataPipegraph based on the custom need. Called once in creatingDataLoader2iterator at first time. Prior to calling this method, theReadingServiceobject must be picklable.- Parameters:
datapipe – Original
DataPipegraph.- Returns:
An adapted or a new
DataPipegraph.