1 #include <torch/nn/modules/container/functional.h> 2 3 #include <torch/types.h> 4 5 #include <functional> 6 #include <utility> 7 8 namespace torch { 9 namespace nn { FunctionalImpl(Function function)10FunctionalImpl::FunctionalImpl(Function function) 11 : function_(std::move(function)) {} 12 reset()13void FunctionalImpl::reset() {} 14 pretty_print(std::ostream & stream) const15void FunctionalImpl::pretty_print(std::ostream& stream) const { 16 stream << "torch::nn::Functional()"; 17 } 18 forward(Tensor input)19Tensor FunctionalImpl::forward(Tensor input) { 20 return function_(std::move(input)); 21 } 22 operator ()(Tensor input)23Tensor FunctionalImpl::operator()(Tensor input) { 24 return forward(std::move(input)); 25 } 26 is_serializable() const27bool FunctionalImpl::is_serializable() const { 28 return false; 29 } 30 } // namespace nn 31 } // namespace torch 32