Caffe2 - C++ API
A deep learning, cross platform ML framework
dataloader_options.h
1 #pragma once
2 
3 #include <torch/arg.h>
4 #include <torch/types.h>
5 
6 #include <chrono>
7 #include <cstddef>
8 
9 namespace torch {
10 namespace data {
11 
14  DataLoaderOptions() = default;
15  /* implicit */ DataLoaderOptions(size_t batch_size)
16  : batch_size_(batch_size) {}
17 
19  TORCH_ARG(size_t, batch_size) = 1;
20 
23  TORCH_ARG(size_t, workers) = 0;
24 
27  TORCH_ARG(optional<size_t>, max_jobs);
28 
31 
35  TORCH_ARG(bool, enforce_ordering) = true;
36 
39  TORCH_ARG(bool, drop_last) = false;
40 };
41 
50  : batch_size(options.batch_size_),
51  workers(options.workers_),
52  max_jobs(options.max_jobs_.value_or(2 * workers)),
53  timeout(options.timeout_),
54  enforce_ordering(options.enforce_ordering_),
55  drop_last(options.drop_last_) {}
56 
57  size_t batch_size;
58  size_t workers;
59  size_t max_jobs;
61  bool enforce_ordering;
62  bool drop_last;
63 };
64 } // namespace data
65 } // namespace torch
TORCH_ARG(size_t, batch_size)
The size of each batch to fetch.
Like DataLoaderOptions, but without any unconfigured state.
Options to configure a DataLoader.
Definition: jit_type.h:17