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

A dataset that wraps another dataset in a shared pointer and implements the BatchDataset API, delegating all calls to the shared instance. More...

#include <shared.h>

Inheritance diagram for torch::data::datasets::SharedBatchDataset< UnderlyingDataset >:
torch::data::datasets::BatchDataset< SharedBatchDataset< UnderlyingDataset >, UnderlyingDataset::BatchType, UnderlyingDataset::BatchRequestType >

Public Types

using BatchType = typename UnderlyingDataset::BatchType
 
using BatchRequestType = typename UnderlyingDataset::BatchRequestType
 
- Public Types inherited from torch::data::datasets::BatchDataset< SharedBatchDataset< UnderlyingDataset >, UnderlyingDataset::BatchType, UnderlyingDataset::BatchRequestType >
using SelfType = SharedBatchDataset< UnderlyingDataset >
 
using BatchType = UnderlyingDataset::BatchType
 
using BatchRequestType = UnderlyingDataset::BatchRequestType
 

Public Member Functions

 SharedBatchDataset (std::shared_ptr< UnderlyingDataset > shared_dataset)
 Constructs a new SharedBatchDataset from a shared_ptr to the UnderlyingDataset. More...
 
BatchType get_batch (BatchRequestType request) override
 Calls get_batch on the underlying dataset.
 
optional< size_t > size () const override
 Returns the size from the underlying dataset.
 
UnderlyingDataset & operator* ()
 Accesses the underlying dataset.
 
const UnderlyingDataset & operator* () const
 Accesses the underlying dataset.
 
UnderlyingDataset * operator-> ()
 Accesses the underlying dataset.
 
const UnderlyingDataset * operator-> () const
 Accesses the underlying dataset.
 
void reset ()
 Calls reset() on the underlying dataset.
 
- Public Member Functions inherited from torch::data::datasets::BatchDataset< SharedBatchDataset< UnderlyingDataset >, UnderlyingDataset::BatchType, UnderlyingDataset::BatchRequestType >
virtual UnderlyingDataset::BatchType get_batch (UnderlyingDataset::BatchRequestTyperequest)=0
 Returns a batch of data given an index.
 
MapDataset< SharedBatchDataset< UnderlyingDataset >, TransformType > map (TransformType transform)&
 Creates a MapDataset that applies the given transform to this dataset.
 
MapDataset< SharedBatchDataset< UnderlyingDataset >, TransformType > map (TransformType transform)&&
 Creates a MapDataset that applies the given transform to this dataset.
 

Additional Inherited Members

- Static Public Attributes inherited from torch::data::datasets::BatchDataset< SharedBatchDataset< UnderlyingDataset >, UnderlyingDataset::BatchType, UnderlyingDataset::BatchRequestType >
static constexpr bool is_stateful
 

Detailed Description

template<typename UnderlyingDataset>
class torch::data::datasets::SharedBatchDataset< UnderlyingDataset >

A dataset that wraps another dataset in a shared pointer and implements the BatchDataset API, delegating all calls to the shared instance.

This is useful when you want all worker threads in the dataloader to access the same dataset instance. The dataset must take care of synchronization and thread-safe access itself.

Use torch::data::datasets::make_shared_dataset() to create a new SharedBatchDataset like you would a std::shared_ptr.

Definition at line 21 of file shared.h.

Constructor & Destructor Documentation

template<typename UnderlyingDataset >
torch::data::datasets::SharedBatchDataset< UnderlyingDataset >::SharedBatchDataset ( std::shared_ptr< UnderlyingDataset >  shared_dataset)
inline

Constructs a new SharedBatchDataset from a shared_ptr to the UnderlyingDataset.

Definition at line 31 of file shared.h.


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