Rate this Page

Template Class SharedBatchDataset#

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 theBatchDataset 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.

Usetorch::data::datasets::make_shared_dataset() to create a newSharedBatchDataset like you would astd::shared_ptr.

Public Types

usingBatchType=typenameUnderlyingDataset::BatchType#
usingBatchRequestType=typenameUnderlyingDataset::BatchRequestType#

Public Functions

inlineSharedBatchDataset(std::shared_ptr<UnderlyingDataset>shared_dataset)#

Constructs a newSharedBatchDataset from ashared_ptr to theUnderlyingDataset.

inlinevirtualBatchTypeget_batch(BatchRequestTyperequest)override#

Callsget_batch on the underlying dataset.

inlinevirtualstd::optional<size_t>size()constoverride#

Returns thesize from 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.

inlinevoidreset()#

Callsreset() on the underlying dataset.