Skip to content

Commit d93a7d0

Browse files
JacobSzwejbkafacebook-github-bot
authored andcommitted
remove executor.h 4/N (#185)
Summary: Pull Request resolved: #185 Updated the runner Reviewed By: dbort Differential Revision: D48851278 fbshipit-source-id: c1972250ab28a71eecf8c68826be7c505c373274
1 parent 834c53f commit d93a7d0

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

test/multi_runner.cpp

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
#include <executorch/extension/data_loader/buffer_data_loader.h>
3333
#include <executorch/runtime/core/error.h>
3434
#include <executorch/runtime/core/result.h>
35-
#include <executorch/runtime/executor/executor.h>
35+
#include <executorch/runtime/executor/method.h>
36+
#include <executorch/runtime/executor/program.h>
3637
#include <executorch/runtime/executor/test/managed_memory_manager.h>
3738
#include <executorch/runtime/platform/log.h>
3839
#include <executorch/runtime/platform/runtime.h>
@@ -59,10 +60,10 @@ DEFINE_validator(num_instances, &validate_positive_int32);
5960
namespace {
6061
using torch::executor::DataLoader;
6162
using torch::executor::Error;
62-
using torch::executor::Executor;
6363
using torch::executor::FreeableBuffer;
6464
using torch::executor::MemoryAllocator;
6565
using torch::executor::MemoryManager;
66+
using torch::executor::Method;
6667
using torch::executor::Program;
6768
using torch::executor::Result;
6869
using torch::executor::testing::ManagedMemoryManager;
@@ -86,22 +87,16 @@ class PreparedModel final {
8687
loader_(model_data, model_data_size),
8788
program_(load_program_or_die(loader_)),
8889
memory_manager_(non_const_mem_bytes, runtime_mem_bytes),
89-
executor_(&program_, &memory_manager_.get()),
90+
method_(load_method_or_die(program_, &memory_manager_.get())),
9091
has_run_(false) {
91-
Error status = executor_.init_execution_plan();
92-
ET_CHECK_MSG(
93-
status == Error::Ok,
94-
"init_execution_plan() failed with status 0x%" PRIx32,
95-
status);
96-
inputs_ =
97-
torch::executor::util::PrepareInputTensors(executor_.execution_plan());
92+
inputs_ = torch::executor::util::PrepareInputTensors(method_);
9893
}
9994

10095
void run() {
10196
ET_CHECK_MSG(!has_run_, "A PreparedModel may only be run once");
10297
has_run_ = true;
10398

104-
Error status = executor_.execution_plan().execute();
99+
Error status = method_.execute();
105100
ET_CHECK_MSG(
106101
status == Error::Ok,
107102
"plan.execute() failed with status 0x%" PRIx32,
@@ -125,11 +120,19 @@ class PreparedModel final {
125120
return std::move(program.get());
126121
}
127122

123+
static Method load_method_or_die(
124+
const Program& program,
125+
MemoryManager* memory_manager) {
126+
Result<Method> method = program.load_method("forward", memory_manager);
127+
ET_CHECK(method.ok());
128+
return std::move(method.get());
129+
}
130+
128131
const std::string name_;
129132
BufferDataLoader loader_; // Needs to outlive program_
130133
Program program_; // Needs to outlive executor_
131134
ManagedMemoryManager memory_manager_; // Needs to outlive executor_
132-
Executor executor_;
135+
Method method_;
133136
exec_aten::ArrayRef<void*> inputs_;
134137

135138
bool has_run_;

test/targets.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def define_common_targets():
5858
deps = [
5959
"//executorch/runtime/core:core",
6060
"//executorch/kernels/portable:generated_lib_all_ops",
61-
"//executorch/runtime/executor:executor",
61+
"//executorch/runtime/executor:program",
6262
"//executorch/runtime/executor/test:managed_memory_manager",
6363
"//executorch/extension/data_loader:buffer_data_loader",
6464
"//executorch/util:read_file",

0 commit comments

Comments
 (0)