Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce size of Method::init #7608

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions runtime/executor/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,10 +688,13 @@ Error Method::init(executorch_flatbuffer::ExecutionPlan* s_plan) {
"Null instruction at index %zu",
instr_idx);

const void* instr_args = instruction->instr_args();
switch (instruction->instr_args_type()) {
case executorch_flatbuffer::InstructionArguments::KernelCall: {
const auto arg_idxs =
instruction->instr_args_as_KernelCall()->args();
const auto* instr_args_as_KernelCall =
static_cast<const executorch_flatbuffer::KernelCall*>(
instr_args);
const auto arg_idxs = instr_args_as_KernelCall->args();
ET_CHECK_OR_RETURN_ERROR(
arg_idxs != nullptr, InvalidProgram, "KernelCall args missing");
auto res = gen_instruction_arguments(
Expand All @@ -705,7 +708,7 @@ Error Method::init(executorch_flatbuffer::ExecutionPlan* s_plan) {
}
chain_instruction_arg_lists[instr_idx] = res.get();
auto err = resolve_operator(
instruction->instr_args_as_KernelCall()->op_index(),
instr_args_as_KernelCall->op_index(),
chain_instruction_kernels,
instr_idx,
res.get(),
Expand All @@ -720,7 +723,9 @@ Error Method::init(executorch_flatbuffer::ExecutionPlan* s_plan) {
} break;
case executorch_flatbuffer::InstructionArguments::DelegateCall: {
const auto arg_idxs =
instruction->instr_args_as_DelegateCall()->args();
static_cast<const executorch_flatbuffer::DelegateCall*>(
instr_args)
->args();
ET_CHECK_OR_RETURN_ERROR(
arg_idxs != nullptr,
InvalidProgram,
Expand All @@ -740,7 +745,9 @@ Error Method::init(executorch_flatbuffer::ExecutionPlan* s_plan) {
// Validate the index at load time so we can trust it during
// execution.
auto index =
instruction->instr_args_as_JumpFalseCall()->cond_value_index();
static_cast<const executorch_flatbuffer::JumpFalseCall*>(
instr_args)
->cond_value_index();
ET_CHECK_OR_RETURN_ERROR(
index >= 0 && index < n_value_,
InvalidProgram,
Expand Down
Loading