3 #include <torch/data/example.h>     4 #include <torch/types.h>     6 #include <c10/util/ArrayRef.h>    10 #include <type_traits>    17 template <
typename S, 
typename T>
    19 template <
typename D, 
typename T>
    38     typename Batch = std::vector<Example<>>,
    42   using SelfType = Self;
    43   using BatchType = Batch;
    44   using BatchRequestType = BatchRequest;
    50   virtual Batch get_batch(BatchRequest request) = 0;
    56   template <
typename TransformType>
    58     return datasets::map(static_cast<Self&>(*
this), std::move(transform));
    62   template <
typename TransformType>
    65         std::move(static_cast<Self&>(*
this)), std::move(transform));
    75 template <
typename Self, 
typename SingleExample = Example<>>
    78   using ExampleType = SingleExample;
    81   virtual ExampleType 
get(
size_t index) = 0;
    87     std::vector<ExampleType> batch;
    88     batch.reserve(indices.
size());
    89     for (
const auto i : indices) {
    90       batch.push_back(
get(i));
    99 template <
typename Self, 
typename Batch = std::vector<Example<>>>
 MapDataset< Self, TransformType > map(TransformType transform)&
Creates a MapDataset that applies the given transform to this dataset. 
 
std::vector< ExampleType > get_batch(ArrayRef< size_t > indices) override
Returns a batch of data. 
 
A dataset that can yield data only in batches. 
 
constexpr size_t size() const 
size - Get the array size. 
 
A dataset that can yield data in batches, or as individual examples. 
 
MapDataset< Self, TransformType > map(TransformType transform)&&
Creates a MapDataset that applies the given transform to this dataset. 
 
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
 
A MapDataset is a dataset that applies a transform to a source dataset.