Caffe2 - C++ API
A deep learning, cross platform ML framework
Public Member Functions | Protected Member Functions | Protected Attributes
torch::data::samplers::DistributedSampler< BatchRequest > Class Template Reference

A Sampler that selects a subset of indices to sample from and defines a sampling behavior. More...

#include <distributed.h>

Inheritance diagram for torch::data::samplers::DistributedSampler< BatchRequest >:
torch::data::samplers::Sampler< BatchRequest >

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

Detailed Description

template<typename BatchRequest = std::vector<size_t>>
class torch::data::samplers::DistributedSampler< 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.

Member Function Documentation

template<typename BatchRequest = std::vector<size_t>>
void torch::data::samplers::DistributedSampler< BatchRequest >::set_epoch ( size_t  epoch)

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.

The documentation for this class was generated from the following file: