Shortcuts

Template Struct ValidIterator

Inheritance Relationships

Base Type

Struct Documentation

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

Public Types

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

Public Functions

inline explicit ValidIterator(BatchProducer next_batch)
inline virtual void next() override

Fetches the next batch.

inline virtual 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.

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

Does double dispatch.

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

A ValidIterator is equal to the SentinelIterator iff.

the ValidIterator has reached the end of the dataloader.

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

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

inline void lazy_initialize() const

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

Public Members

BatchProducer next_batch_
mutable std::optional<Batch> batch_
mutable bool initialized_ = false

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