Skip to content

Commit 67e4483

Browse files
dbortfacebook-github-bot
authored andcommitted
Check for missing chain instructions (#1510)
Summary: Pull Request resolved: #1510 Don't use the `instructions` field of `Chain` unless it's present. Reviewed By: larryliu0820 Differential Revision: D52451741 fbshipit-source-id: d1a09f30d3b46196bb756244c1e8867ad4be483c
1 parent eb4744e commit 67e4483

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

runtime/executor/method.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,17 +598,23 @@ Error Method::init(executorch_flatbuffer::ExecutionPlan* s_plan) {
598598
int32_t num_instructions_missing_op = 0;
599599
for (size_t i = 0; i < n_chains_; ++i) {
600600
auto s_chain = chains->Get(i);
601-
auto num_instructions = s_chain->instructions()->size();
601+
auto s_instructions = s_chain->instructions();
602+
ET_CHECK_OR_RETURN_ERROR(
603+
s_instructions != nullptr,
604+
InvalidProgram,
605+
"Missing instructions in chain %zu",
606+
i);
607+
auto num_instructions = s_instructions->size();
602608
auto chain_instruction_kernels = ET_ALLOCATE_LIST_OR_RETURN_ERROR(
603609
method_allocator, OpFunction, num_instructions);
604610
auto chain_instruction_arg_lists = ET_ALLOCATE_LIST_OR_RETURN_ERROR(
605611
method_allocator, InstructionArgs, num_instructions);
606612

607613
// Set up the argument lists ahead of time and store pointers to them to
608614
// use when the instructions are called
609-
for (size_t instr_idx = 0; instr_idx < s_chain->instructions()->size();
615+
for (size_t instr_idx = 0; instr_idx < s_instructions->size();
610616
++instr_idx) {
611-
const auto instruction = s_chain->instructions()->Get(instr_idx);
617+
const auto instruction = s_instructions->Get(instr_idx);
612618
switch (instruction->instr_args_type()) {
613619
case executorch_flatbuffer::InstructionArguments::KernelCall: {
614620
const auto arg_idxs =

0 commit comments

Comments
 (0)