@@ -598,17 +598,23 @@ Error Method::init(executorch_flatbuffer::ExecutionPlan* s_plan) {
598
598
int32_t num_instructions_missing_op = 0 ;
599
599
for (size_t i = 0 ; i < n_chains_; ++i) {
600
600
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 ();
602
608
auto chain_instruction_kernels = ET_ALLOCATE_LIST_OR_RETURN_ERROR (
603
609
method_allocator, OpFunction, num_instructions);
604
610
auto chain_instruction_arg_lists = ET_ALLOCATE_LIST_OR_RETURN_ERROR (
605
611
method_allocator, InstructionArgs, num_instructions);
606
612
607
613
// Set up the argument lists ahead of time and store pointers to them to
608
614
// 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 ();
610
616
++instr_idx) {
611
- const auto instruction = s_chain-> instructions () ->Get (instr_idx);
617
+ const auto instruction = s_instructions ->Get (instr_idx);
612
618
switch (instruction->instr_args_type ()) {
613
619
case executorch_flatbuffer::InstructionArguments::KernelCall: {
614
620
const auto arg_idxs =
0 commit comments