Template Class SharedBatchDataset#
Defined inFile shared.h
Inheritance Relationships#
Base Type#
publictorch::data::datasets::BatchDataset<SharedBatchDataset<UnderlyingDataset>,UnderlyingDataset::BatchType,UnderlyingDataset::BatchRequestType>(Template Class BatchDataset)
Class Documentation#
- template<typenameUnderlyingDataset>
classSharedBatchDataset:publictorch::data::datasets::BatchDataset<SharedBatchDataset<UnderlyingDataset>,UnderlyingDataset::BatchType,UnderlyingDataset::BatchRequestType># A dataset that wraps another dataset in a shared pointer and implements the
BatchDatasetAPI, 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 newSharedBatchDatasetlike you would astd::shared_ptr.Public Types
- usingBatchType=typenameUnderlyingDataset::BatchType#
- usingBatchRequestType=typenameUnderlyingDataset::BatchRequestType#
Public Functions
- inlineSharedBatchDataset(std::shared_ptr<UnderlyingDataset>shared_dataset)#
Constructs a new
SharedBatchDatasetfrom ashared_ptrto theUnderlyingDataset.
- inlinevirtualBatchTypeget_batch(BatchRequestTyperequest)override#
Calls
get_batchon the underlying dataset.
- inlinevirtualstd::optional<size_t>size()constoverride#
Returns the
sizefrom the underlying dataset.
- inlineUnderlyingDataset&operator*()#
Accesses the underlying dataset.
- inlineconstUnderlyingDataset&operator*()const#
Accesses the underlying dataset.
- inlineUnderlyingDataset*operator->()#
Accesses the underlying dataset.
- inlineconstUnderlyingDataset*operator->()const#
Accesses the underlying dataset.
- usingBatchType=typenameUnderlyingDataset::BatchType#