Shortcuts

Template Class SharedBatchDataset

Inheritance Relationships

Base Type

  • public torch::data::datasets::BatchDataset< SharedBatchDataset< UnderlyingDataset >, UnderlyingDataset::BatchType, UnderlyingDataset::BatchRequestType > (Template Class BatchDataset)

Class Documentation

template<typename UnderlyingDataset>
class torch::data::datasets::SharedBatchDataset : public torch::data::datasets::BatchDataset<SharedBatchDataset<UnderlyingDataset>, UnderlyingDataset::BatchType, UnderlyingDataset::BatchRequestType>

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.

Public Types

using BatchType = typename UnderlyingDataset::BatchType
using BatchRequestType = typename UnderlyingDataset::BatchRequestType

Public Functions

SharedBatchDataset(std::shared_ptr<UnderlyingDataset> shared_dataset)

Constructs a new SharedBatchDataset from a shared_ptr to the UnderlyingDataset.

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.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources