@@ -73,23 +73,23 @@ class Module final {
7373 loader_.get (), Program::Verification::InternalConsistency);
7474 THROW_IF_ERROR (
7575 program.error (),
76- " Failed to deserialize program : 0x%" PRIx32,
76+ " loading program failed with error : 0x%" PRIx32,
7777 program.error ());
7878 program_ = std::make_unique<Program>(std::move (program.get ()));
7979 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 () ;
8181 // It's safe to use the same memory manager for all modules because
8282 // we can guarantee that only one will be executing at a time.
8383 // 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);
8785 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 ()))});
9393 }
9494 }
9595
@@ -122,13 +122,13 @@ class Module final {
122122 run_method_return_type run_method_internal (
123123 const std::string& method_name,
124124 run_method_inputs_type args) {
125- auto & plan = methods_[method_name]-> execution_plan () ;
125+ auto & method = methods_[method_name];
126126 exec_aten::ArrayRef<EValue> input_evalue_list (args.data (), args.size ());
127127
128- Error set_inputs_status = plan. set_inputs (input_evalue_list);
128+ Error set_inputs_status = method-> set_inputs (input_evalue_list);
129129 THROW_IF_ERROR (
130130 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,
132132 method_name.c_str (),
133133 set_inputs_status);
134134
@@ -145,29 +145,29 @@ class Module final {
145145 c10::impl::ExcludeDispatchKeyGuard no_autograd (
146146 c10::autograd_dispatch_keyset);
147147#endif
148- Error execute_status = plan. execute ();
148+ Error execute_status = method-> execute ();
149149 THROW_IF_ERROR (
150150 execute_status,
151- " execution_plan(). execute() failed with error 0x%" PRIx32,
151+ " method-> execute() failed with error 0x%" PRIx32,
152152 execute_status);
153153 // process outputs
154- std::vector<EValue> result (plan. outputs_size ());
154+ std::vector<EValue> result (method-> outputs_size ());
155155
156156 Error get_outputs_status =
157- plan. get_outputs (result.data (), plan. outputs_size ());
157+ method-> get_outputs (result.data (), method-> outputs_size ());
158158 THROW_IF_ERROR (
159159 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,
161161 method_name.c_str (),
162162 get_outputs_status);
163163
164164 return result;
165165 }
166166
167167 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_;
171171};
172172
173173inline std::unique_ptr<Module> load_from_buffer (
0 commit comments