xref: /aosp_15_r20/external/pytorch/torch/csrc/api/src/nn/modules/container/functional.cpp (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
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)10 FunctionalImpl::FunctionalImpl(Function function)
11     : function_(std::move(function)) {}
12 
reset()13 void FunctionalImpl::reset() {}
14 
pretty_print(std::ostream & stream) const15 void FunctionalImpl::pretty_print(std::ostream& stream) const {
16   stream << "torch::nn::Functional()";
17 }
18 
forward(Tensor input)19 Tensor FunctionalImpl::forward(Tensor input) {
20   return function_(std::move(input));
21 }
22 
operator ()(Tensor input)23 Tensor FunctionalImpl::operator()(Tensor input) {
24   return forward(std::move(input));
25 }
26 
is_serializable() const27 bool FunctionalImpl::is_serializable() const {
28   return false;
29 }
30 } // namespace nn
31 } // namespace torch
32