Files
pytorch/docs/cpp/source/api/data/samplers.md
T
Svetlana Karslioglu 19da3da3d3 Restructure C++ docs (#174096)
The fix-cpp-build branch is a major restructuring that:

- Drops Exhale (which auto-generated API docs but caused OOM in CI) in favor of hand-written RST pages using Breathe directives
- Reorganizes notes into a hierarchical API reference with proper categories
- Adds new content: XPU docs, stable ABI docs, DeviceGuard/Stream docs
- Always runs Doxygen instead of gating on an env var

Pull Request resolved: https://github.com/pytorch/pytorch/pull/174096
Approved by: https://github.com/janeyx99, https://github.com/seemethere, https://github.com/albanD
2026-04-07 17:24:38 +00:00

1.5 KiB

myst
myst
html_meta
description keywords
Data samplers in PyTorch C++ — RandomSampler, SequentialSampler, DistributedRandomSampler, and StreamSampler. PyTorch, C++, sampler, RandomSampler, SequentialSampler, DistributedRandomSampler

Samplers

Samplers control the order in which samples are accessed from a dataset. They determine the indices that the DataLoader uses to fetch data.

Sampler Base Class

:members:
:undoc-members:

Sequential Sampler

Accesses samples in order from 0 to N-1. Use this for evaluation or when order matters.

:members:
:undoc-members:

Random Sampler

Accesses samples in random order. Use this for training to ensure the model sees samples in different orders each epoch.

:members:
:undoc-members:

Distributed Random Sampler

For distributed training, ensures each process gets a different subset of the data without overlap.

:members:
:undoc-members:

Distributed Sampler (Base)

:members:
:undoc-members:

Distributed Sequential Sampler

:members:
:undoc-members:

Stream Sampler

:members:
:undoc-members: