A Sampler
that selects a subset of indices to sample from and defines a sampling behavior.
More...
#include <distributed.h>
Public Member Functions | |
TORCH_API | DistributedSampler (size_t size, size_t num_replicas=1, size_t rank=0, bool allow_duplicates=true) |
void | set_epoch (size_t epoch) |
Set the epoch for the current enumeration. More... | |
size_t | epoch () const |
Public Member Functions inherited from torch::data::samplers::Sampler< BatchRequest > | |
virtual TORCH_API void | reset (optional< size_t > new_size)=0 |
Resets the Sampler 's internal state. More... | |
virtual TORCH_API optional< BatchRequest > | next (size_t batch_size)=0 |
Returns the next index if possible, or an empty optional if the sampler is exhausted for this epoch. More... | |
virtual TORCH_API void | save (serialize::OutputArchive &archive) const =0 |
Serializes the Sampler to the archive . | |
virtual TORCH_API void | load (serialize::InputArchive &archive)=0 |
Deserializes the Sampler from the archive . | |
Protected Member Functions | |
size_t | local_sample_count () |
Protected Attributes | |
size_t | size_ |
size_t | num_replicas_ |
size_t | rank_ |
size_t | epoch_ |
bool | allow_duplicates_ |
Additional Inherited Members | |
Public Types inherited from torch::data::samplers::Sampler< BatchRequest > | |
using | BatchRequestType = BatchRequest |
A Sampler
that selects a subset of indices to sample from and defines a sampling behavior.
In a distributed setting, this selects a subset of the indices depending on the provided num_replicas and rank parameters. The Sampler
performs a rounding operation based on the allow_duplicates
parameter to decide the local sample count.
Definition at line 26 of file distributed.h.
|
inline |
Set the epoch for the current enumeration.
This can be used to alter the sample selection and shuffling behavior.
Definition at line 41 of file distributed.h.