Template Struct ValidIterator

Inheritance Relationships

Base Type

Struct Documentation

template<typename Batch>
struct torch::data::detail::ValidIterator : public torch::data::detail::IteratorImpl<Batch>

Public Types

using BatchProducer = std::function<optional<Batch>()>

Public Functions

ValidIterator(BatchProducer next_batch)
void next() override

Fetches the next batch.

Batch &get() override

Returns the current batch.

The precondition for this operation to not throw an exception is that it has been compared to the SentinelIterator and did not compare equal.

bool operator==(const IteratorImpl<Batch> &other) const override

Does double dispatch.

bool operator==(const SentinelIterator<Batch>&) const override

A ValidIterator is equal to the SentinelIterator iff.

the ValidIterator has reached the end of the dataloader.

bool operator==(const ValidIterator<Batch> &other) const override

Returns true if the memory address of other equals that of this.

void lazy_initialize() const

Gets the very first batch if it has not yet been fetched.

Public Members

BatchProducer next_batch_
optional<Batch> batch_
bool initialized_ = false


Access comprehensive developer documentation for PyTorch

View Docs


Get in-depth tutorials for beginners and advanced developers

View Tutorials


Find development resources and get your questions answered

View Resources