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>
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 |
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
.
|
inline |
Constructs a new SharedBatchDataset
from a shared_ptr
to the UnderlyingDataset
.