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)

RoutedDecoder

class torchdata.datapipes.iter.RoutedDecoder(datapipe: ~Iterable[~Tuple[str, ~io.BufferedIOBase]], *handlers: ~Callable, key_fn: ~Callable = <function extension_extract_fn>)

Decodes binary streams from input DataPipe, yields pathname and decoded data in a tuple.

(functional name: routed_decode)

Parameters:
  • datapipe – Iterable datapipe that provides pathname and binary stream in tuples

  • handlers – Optional user defined decoder handlers. If None, basic and image decoder handlers will be set as default. If multiple handles are provided, the priority order follows the order of handlers (the first handler has the top priority)

  • key_fn – Function for decoder to extract key from pathname to dispatch handlers. Default is set to extract file extension from pathname

Note

When key_fn is specified returning anything other than extension, the default handler will not work and users need to specify custom handler. Custom handler could use regex to determine the eligibility to handle data.

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