1#pragma once
2
3#include <vector>
4
5#include <ATen/core/ivalue.h>
6#include <ATen/core/operator_name.h>
7#include <torch/csrc/jit/runtime/instruction.h>
8
9namespace torch {
10namespace jit {
11namespace mobile {
12
13using Stack = std::vector<c10::IValue>;
14using DebugHandle = int64_t;
15
16class Function;
17
18// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
19struct Code {
20 std::vector<Instruction> instructions_;
21 std::vector<DebugHandle> debug_handles_;
22 std::vector<c10::OperatorName> op_names_;
23 std::vector<int> operator_input_sizes_;
24 std::vector<std::function<void(Stack&)>> operators_;
25 std::vector<c10::IValue> constants_;
26 std::vector<c10::TypePtr> types_;
27 // TODO After we actually export CALL instructions we can remove this.
28 // We may need a two-stage importing scheme, where we firstly construct all
29 // function objects, and then append referenced function pointers. This could
30 // be done in parseMethods().
31 std::vector<mobile::Function*> functions_;
32 size_t register_size_ = 0; // Aggregated output size.
33 // initialized means operators_ array is filled with operators
34 bool initialized = false;
35};
36
37} // namespace mobile
38} // namespace jit
39} // namespace torch
40