@@ -73,23 +73,23 @@ class Module final {
73
73
loader_.get (), Program::Verification::InternalConsistency);
74
74
THROW_IF_ERROR (
75
75
program.error (),
76
- " Failed to deserialize program : 0x%" PRIx32,
76
+ " loading program failed with error : 0x%" PRIx32,
77
77
program.error ());
78
78
program_ = std::make_unique<Program>(std::move (program.get ()));
79
79
for (size_t i = 0 ; i < program_->num_methods (); ++i) {
80
- auto name = program_->get_method_name (i);
80
+ auto name = program_->get_method_name (i). get () ;
81
81
// It's safe to use the same memory manager for all modules because
82
82
// we can guarantee that only one will be executing at a time.
83
83
// Everything in this module runs on a single thread.
84
- auto executor =
85
- std::make_unique<Executor>(program_.get (), memory_manager);
86
- auto status = executor->init_execution_plan (name.get ());
84
+ Result<Method> method = program_->load_method (name, memory_manager);
87
85
THROW_IF_ERROR (
88
- status,
89
- " initializing executor for method %s failed with error 0x:%" PRIx32,
90
- name.get (),
91
- status);
92
- methods_.insert ({std::string (name.get ()), std::move (executor)});
86
+ method.error (),
87
+ " loading method %s failed with error 0x%" PRIx32,
88
+ name,
89
+ method.error ());
90
+ methods_.insert (
91
+ {std::string (name),
92
+ std::make_unique<Method>(std::move (method.get ()))});
93
93
}
94
94
}
95
95
@@ -122,13 +122,13 @@ class Module final {
122
122
run_method_return_type run_method_internal (
123
123
const std::string& method_name,
124
124
run_method_inputs_type args) {
125
- auto & plan = methods_[method_name]-> execution_plan () ;
125
+ auto & method = methods_[method_name];
126
126
exec_aten::ArrayRef<EValue> input_evalue_list (args.data (), args.size ());
127
127
128
- Error set_inputs_status = plan. set_inputs (input_evalue_list);
128
+ Error set_inputs_status = method-> set_inputs (input_evalue_list);
129
129
THROW_IF_ERROR (
130
130
set_inputs_status,
131
- " plan. set_inputs() for method '%s' failed with error 0x%" PRIx32,
131
+ " method-> set_inputs() for method '%s' failed with error 0x%" PRIx32,
132
132
method_name.c_str (),
133
133
set_inputs_status);
134
134
@@ -145,29 +145,29 @@ class Module final {
145
145
c10::impl::ExcludeDispatchKeyGuard no_autograd (
146
146
c10::autograd_dispatch_keyset);
147
147
#endif
148
- Error execute_status = plan. execute ();
148
+ Error execute_status = method-> execute ();
149
149
THROW_IF_ERROR (
150
150
execute_status,
151
- " execution_plan(). execute() failed with error 0x%" PRIx32,
151
+ " method-> execute() failed with error 0x%" PRIx32,
152
152
execute_status);
153
153
// process outputs
154
- std::vector<EValue> result (plan. outputs_size ());
154
+ std::vector<EValue> result (method-> outputs_size ());
155
155
156
156
Error get_outputs_status =
157
- plan. get_outputs (result.data (), plan. outputs_size ());
157
+ method-> get_outputs (result.data (), method-> outputs_size ());
158
158
THROW_IF_ERROR (
159
159
get_outputs_status,
160
- " plan. get_outputs() for method '%s' failed with error 0x%" PRIx32,
160
+ " method-> get_outputs() for method '%s' failed with error 0x%" PRIx32,
161
161
method_name.c_str (),
162
162
get_outputs_status);
163
163
164
164
return result;
165
165
}
166
166
167
167
std::shared_ptr<char > mem_to_delete_; // loader_ may point to this.
168
- std::shared_ptr <DataLoader> loader_; // program_ points to this.
169
- std::unique_ptr<const Program> program_; // executor_ points to this.
170
- std::unordered_map<std::string, std::unique_ptr<Executor >> methods_;
168
+ std::unique_ptr <DataLoader> loader_; // program_ points to this.
169
+ std::unique_ptr<const Program> program_; // methods_ entries points to this.
170
+ std::unordered_map<std::string, std::unique_ptr<Method >> methods_;
171
171
};
172
172
173
173
inline std::unique_ptr<Module> load_from_buffer (
0 commit comments