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