Caffe2 - C++ API
A deep learning, cross platform ML framework
Public Types | Public Member Functions
torch::data::StatelessDataLoader< Dataset, Sampler > Class Template Reference

A dataloader for stateless datasets. More...

#include <stateless.h>

Inheritance diagram for torch::data::StatelessDataLoader< Dataset, Sampler >:
torch::data::DataLoaderBase< Dataset, Dataset::BatchType, Sampler::BatchRequestType >

Public Types

using super = DataLoaderBase< Dataset, typename Dataset::BatchType, typename Sampler::BatchRequestType >
 
using BatchRequestType = BatchRequest
 
- Public Types inherited from torch::data::DataLoaderBase< Dataset, Dataset::BatchType, Sampler::BatchRequestType >
using BatchType = Dataset::BatchType
 
using BatchRequestType = Sampler::BatchRequestType
 

Public Member Functions

 StatelessDataLoader (Dataset dataset, Sampler sampler, DataLoaderOptions options)
 Constructs the StatelessDataLoader from a dataset, a sampler and some options. More...
 
- Public Member Functions inherited from torch::data::DataLoaderBase< Dataset, Dataset::BatchType, Sampler::BatchRequestType >
 DataLoaderBase (DataLoaderOptions options, std::unique_ptr< Dataset > main_thread_dataset=nullptr)
 Constructs a new DataLoader from a dataset to sample from, options to configure the DataLoader with, and a sampler that specifies the sampling strategy. More...
 
Iterator< Dataset::BatchType > begin ()
 Returns an iterator into the DataLoader. More...
 
Iterator< Dataset::BatchType > end ()
 Returns a special "sentinel" iterator that compares equal with a non-sentinel iterator once the DataLoader is exhausted. More...
 
void join ()
 Joins the DataLoader's worker threads and drains internal queues. More...
 
const FullDataLoaderOptionsoptions () const noexcept
 Returns the options with which the DataLoader was configured.
 

Additional Inherited Members

- Protected Member Functions inherited from torch::data::DataLoaderBase< Dataset, Dataset::BatchType, Sampler::BatchRequestType >
void prefetch (size_t requested_jobs)
 Schedules requested_jobs many new batches to be fetched. More...
 
void prefetch ()
 Schedules the maximum number of jobs (based on the max_jobs option).
 
optional< BatchType > next ()
 Returns the next batch of data, or an empty optional if the DataLoader is exhausted. More...
 
void worker_thread (Dataset &dataset)
 The function that worker threads run.
 
void push_job (T value)
 Convenience method that calls shuttle_.push_job() with the next sequence number. More...
 
optional< Result > pop_result ()
 Convenience method that gets the next result from the sequencer.
 
std::unique_ptr< detail::sequencers::Sequencer< Result > > new_sequencer ()
 Convenience method that creates a new sequencer based on the enforce_ordering option. More...
 
- Protected Attributes inherited from torch::data::DataLoaderBase< Dataset, Dataset::BatchType, Sampler::BatchRequestType >
const FullDataLoaderOptions options_
 The options the DataLoader was configured with.
 
std::unique_ptr< Dataset > main_thread_dataset_
 The dataset for the main thread, only has a value if the number of worker threads was configured as zero, meaning the main thread has to do all the work (synchronously). More...
 
size_t sequence_number_
 The sequence number for the next batch to be retrieved from the dataset. More...
 
std::vector< std::thread > workers_
 The worker threads, running the worker_thread() method.
 
detail::DataShuttle< Job, Result > shuttle_
 The DataShuttle which takes care of the life cycle of a job.
 
std::unique_ptr< detail::sequencers::Sequencer< Result > > sequencer_
 The Sequencer, which handles optional ordering of batches.
 
bool joined_
 True if the DataLoader has joined its worker threads.
 

Detailed Description

template<typename Dataset, typename Sampler>
class torch::data::StatelessDataLoader< Dataset, Sampler >

A dataloader for stateless datasets.

This dataloader follows the traditional PyTorch dataloader design, whereby a (posssibly) stateful sampler produces batch requests for a stateless dataset, which acts as a simple batch request to batch mapping. The batch request will often be an array of indices, and if the dataset is a simple image dataset, the dataset would produce the images at those indices.

Definition at line 25 of file stateless.h.

Constructor & Destructor Documentation

template<typename Dataset , typename Sampler >
torch::data::StatelessDataLoader< Dataset, Sampler >::StatelessDataLoader ( Dataset  dataset,
Sampler  sampler,
DataLoaderOptions  options 
)
inline

Constructs the StatelessDataLoader from a dataset, a sampler and some options.

Definition at line 38 of file stateless.h.


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