3 #include <torch/data/transforms/base.h> 11 namespace transforms {
14 template <
typename Input,
typename Output = Input>
19 using FunctionType = std::function<OutputBatchType(InputBatchType)>;
23 : function_(
std::move(function)) {}
26 OutputBatchType
apply_batch(InputBatchType input_batch)
override {
27 return function_(std::move(input_batch));
31 FunctionType function_;
35 template <
typename Input,
typename Output = Input>
38 using typename Transform<Input, Output>::InputType;
40 using FunctionType = std::function<Output(Input)>;
43 explicit Lambda(FunctionType
function) : function_(
std::move(function)) {}
47 return function_(std::move(input));
51 FunctionType function_;