diff --git a/runtime/executor/method.cpp b/runtime/executor/method.cpp index 474afc446d2..66edce2a20f 100644 --- a/runtime/executor/method.cpp +++ b/runtime/executor/method.cpp @@ -1060,6 +1060,19 @@ Error Method::init( n_value_); chain_instruction_arg_lists[instr_idx] = InstructionArgs(); } break; + case executorch_flatbuffer::InstructionArguments::FreeCall: { + auto index = + static_cast( + instr_args) + ->value_index(); + ET_CHECK_OR_RETURN_ERROR( + index >= 0 && static_cast(index) < n_value_, + InvalidProgram, + "Index %zd negative or >= %" ET_PRIsize_t, + static_cast(index), + n_value_); + chain_instruction_arg_lists[instr_idx] = InstructionArgs(); + } break; default: { chain_instruction_arg_lists[instr_idx] = InstructionArgs(); } break; @@ -1501,7 +1514,7 @@ Error Method::execute_instruction() { // We know that instr_args_as_FreeCall is non-null because it was checked // at init time. auto free_call = instruction->instr_args_as_FreeCall(); - auto t = values_[free_call->value_index()].toTensor(); + auto t = mutable_value(free_call->value_index()).toTensor(); internal::reset_data_ptr(t); } break; default: