1 #pragma once 2 3 #include <ATen/core/ivalue.h> 4 #include <torch/csrc/jit/mobile/function.h> 5 6 namespace torch::jit::mobile { 7 8 class Module; 9 10 struct TORCH_API Method { 11 Method(const Module* owner, Function* function); 12 13 void run(Stack& stack) const; runMethod14 void run(Stack&& stack) const { 15 run(stack); 16 } 17 18 c10::IValue operator()(std::vector<c10::IValue> stack) const; 19 nameMethod20 const std::string& name() const { 21 return function_->name(); 22 } 23 get_debug_handleMethod24 int64_t get_debug_handle(size_t pc) const { 25 return function_->get_debug_handle(pc); 26 } 27 functionMethod28 Function& function() const { 29 return *function_; 30 } 31 32 private: 33 // Methods are uniquely owned by a single module. 34 // This raw pointer allows referencing the module 35 const Module* owner_; 36 37 // Underlying unbound function 38 Function* function_; 39 }; 40 41 } // namespace torch::jit::mobile 42