Shortcuts

Struct DataLoaderOptions

Page Contents

Struct Documentation

struct DataLoaderOptions

Options to configure a DataLoader.

Public Functions

DataLoaderOptions() = default
inline DataLoaderOptions(size_t batch_size)
inline auto batch_size(const size_t &new_batch_size) -> decltype(*this)

The size of each batch to fetch.

inline auto batch_size(size_t &&new_batch_size) -> decltype(*this)
inline const size_t &batch_size() const noexcept
inline size_t &batch_size() noexcept
inline auto workers(const size_t &new_workers) -> decltype(*this)

The number of worker threads to launch.

If zero, the main thread will synchronously perform the data loading.

inline auto workers(size_t &&new_workers) -> decltype(*this)
inline const size_t &workers() const noexcept
inline size_t &workers() noexcept
inline auto max_jobs(const std::optional<size_t> &new_max_jobs) -> decltype(*this)

The maximum number of jobs to enqueue for fetching by worker threads.

Defaults to two times the number of worker threads.

inline auto max_jobs(std::optional<size_t> &&new_max_jobs) -> decltype(*this)
inline const std::optional<size_t> &max_jobs() const noexcept
inline std::optional<size_t> &max_jobs() noexcept
inline auto timeout(const std::optional<std::chrono::milliseconds> &new_timeout) -> decltype(*this)

An optional limit on the time to wait for the next batch.

inline auto timeout(std::optional<std::chrono::milliseconds> &&new_timeout) -> decltype(*this)
inline const std::optional<std::chrono::milliseconds> &timeout() const noexcept
inline std::optional<std::chrono::milliseconds> &timeout() noexcept
inline auto enforce_ordering(const bool &new_enforce_ordering) -> decltype(*this)

Whether to enforce ordering of batches when multiple are loaded asynchronously by worker threads.

Set to false for better performance if you do not care about determinism.

inline auto enforce_ordering(bool &&new_enforce_ordering) -> decltype(*this)
inline const bool &enforce_ordering() const noexcept
inline bool &enforce_ordering() noexcept
inline auto drop_last(const bool &new_drop_last) -> decltype(*this)

Whether to omit the last batch if it contains less than batch_size examples.

inline auto drop_last(bool &&new_drop_last) -> decltype(*this)
inline const bool &drop_last() const noexcept
inline bool &drop_last() noexcept

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