Caffe2 - C++ API
A deep learning, cross platform ML framework
sequential.h
1 #pragma once
2 
3 #include <torch/csrc/WindowsTorchApiMacro.h>
4 #include <torch/data/samplers/base.h>
5 #include <torch/types.h>
6 
7 #include <cstddef>
8 #include <vector>
9 
10 namespace torch {
11 namespace serialize {
12 class OutputArchive;
13 class InputArchive;
14 } // namespace serialize
15 } // namespace torch
16 
17 namespace torch {
18 namespace data {
19 namespace samplers {
20 
22 class SequentialSampler : public Sampler<> {
23  public:
26  TORCH_API explicit SequentialSampler(size_t size);
27 
29  TORCH_API void reset(optional<size_t> new_size = nullopt) override;
30 
32  TORCH_API optional<std::vector<size_t>> next(size_t batch_size) override;
33 
35  TORCH_API void save(serialize::OutputArchive& archive) const override;
36 
38  TORCH_API void load(serialize::InputArchive& archive) override;
39 
41  TORCH_API size_t index() const noexcept;
42 
43  private:
44  size_t size_;
45  size_t index_{0};
46 };
47 
48 } // namespace samplers
49 } // namespace data
50 } // namespace torch
A Sampler is an object that yields an index with which to access a dataset.
Definition: base.h:23
Definition: jit_type.h:17
A Sampler that returns indices sequentially.
Definition: sequential.h:22
A recursive representation of tensors that can be deserialized from a file or stream.
Definition: input-archive.h:32