Skip to content

Commit c1291ce

Browse files
JacobSzwejbkafacebook-github-bot
authored andcommitted
use Method not ExecutionPlan or Executor (#98)
Summary: Pull Request resolved: #98 title Differential Revision: https://internalfb.com/D48576051 fbshipit-source-id: 6ad2d696635737043ae3ff6097601597f2c98478
1 parent 3e856c7 commit c1291ce

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

exir/backend/test/test_backends.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ def forward(self, x):
345345
def test_backend_with_compiler_out_of_range(self, extract_segments: bool):
346346
with self.assertRaisesRegex(
347347
RuntimeError,
348-
"initializing executor for method forward failed with error 0x:12",
348+
"loading method forward failed with error 0x12",
349349
):
350350
self.run_model_in_unsupported_backend(extract_segments=extract_segments)
351351

exir/backend/test/test_backends_lifted.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ def forward(self, x):
354354
def test_backend_with_compiler_out_of_range(self, extract_segments: bool):
355355
with self.assertRaisesRegex(
356356
RuntimeError,
357-
"initializing executor for method forward failed with error 0x:12",
357+
"loading method forward failed with error 0x12",
358358
):
359359
self.run_model_in_unsupported_backend(extract_segments=extract_segments)
360360

extension/pybindings/module.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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

173173
inline std::unique_ptr<Module> load_from_buffer(

0 commit comments

Comments
 (0)