:github_url: https://github.com/pytorch/pytorch .. _program_listing_file_torch_csrc_api_include_torch_data_samplers_stream.h: Program Listing for File stream.h ================================= |exhale_lsh| :ref:`Return to documentation for file ` (``torch/csrc/api/include/torch/data/samplers/stream.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include #include #include #include #include namespace torch::serialize { class InputArchive; class OutputArchive; } // namespace torch::serialize namespace torch::data::samplers { struct TORCH_API BatchSize : public CustomBatchRequest { explicit BatchSize(size_t size); size_t size() const noexcept override; operator size_t() const noexcept; size_t size_; }; class TORCH_API StreamSampler : public Sampler { public: explicit StreamSampler(size_t epoch_size); void reset(std::optional new_size = std::nullopt) override; std::optional next(size_t batch_size) override; void save(serialize::OutputArchive& archive) const override; void load(serialize::InputArchive& archive) override; private: size_t examples_retrieved_so_far_ = 0; size_t epoch_size_; }; } // namespace torch::data::samplers