:github_url: https://github.com/pytorch/pytorch .. _program_listing_file_torch_csrc_api_include_torch_data_datasets_stateful.h: Program Listing for File stateful.h =================================== |exhale_lsh| :ref:`Return to documentation for file ` (``torch/csrc/api/include/torch/data/datasets/stateful.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include #include #include #include namespace torch::serialize { class OutputArchive; class InputArchive; } // namespace torch::serialize namespace torch::data::datasets { template < typename Self, typename Batch = std::vector>, typename BatchRequest = size_t> class StatefulDataset : public BatchDataset, BatchRequest> { public: virtual void reset() = 0; virtual void save(serialize::OutputArchive& archive) const = 0; virtual void load(serialize::InputArchive& archive) = 0; }; template serialize::OutputArchive& operator<<( serialize::OutputArchive& archive, const StatefulDataset& statefulDataset) { statefulDataset.save(archive); return archive; } template serialize::InputArchive& operator>>( serialize::InputArchive& archive, StatefulDataset& statefulDataset) { statefulDataset.load(archive); return archive; } } // namespace torch::data::datasets