@@ -44,7 +44,8 @@ class BackendDelegate final {
4444 *
4545 * @param[in] delegate The serialized backend delegate to load.
4646 * @param[in] program The serialized program to load from.
47- * @param[in] runtime_allocator Allocator for creating runtime C++ objects.
47+ * @param[in] backend_init_context The context pointer to pass to the
48+ * backend's init() method.
4849 * @param[out] out The BackendDelegate to initialize.
4950 *
5051 * @returns Error::Ok if the initialization succeeded, or an error otherwise.
@@ -212,12 +213,12 @@ struct Chain {
212213namespace {
213214
214215Result<InstructionArgs> gen_instruction_arguments (
215- MemoryAllocator* runtime_allocator ,
216+ MemoryAllocator* method_allocator ,
216217 EValue* values,
217218 size_t num_args,
218219 const int32_t * arg_idxs) {
219220 EValue** arg_list =
220- ET_ALLOCATE_LIST_OR_RETURN_ERROR (runtime_allocator , EValue*, num_args);
221+ ET_ALLOCATE_LIST_OR_RETURN_ERROR (method_allocator , EValue*, num_args);
221222 for (size_t i = 0 ; i < num_args; ++i) {
222223 arg_list[i] = &values[arg_idxs[i]];
223224 }
@@ -267,7 +268,7 @@ Error Method::parse_values() {
267268 ET_CHECK (flatbuffer_values != nullptr );
268269 size_t n_value = flatbuffer_values->size ();
269270 values_ = ET_ALLOCATE_LIST_OR_RETURN_ERROR (
270- memory_manager_->get_runtime_allocator (), EValue, n_value);
271+ memory_manager_->method_allocator (), EValue, n_value);
271272
272273 // n_value_ counts the number of successfully-initialized values for ~Method()
273274 // to clean up, and is incremented at the bottom of the loop. This makes it
@@ -299,10 +300,10 @@ Error Method::parse_values() {
299300 // Allocate space for boxed and unboxed list representations using
300301 // values_ as source of truth
301302 auto * evalp_list =
302- memory_manager_->get_runtime_allocator ()->allocateList <EValue*>(
303+ memory_manager_->method_allocator ()->allocateList <EValue*>(
303304 items->size ());
304305 auto * int_list =
305- memory_manager_->get_runtime_allocator ()->allocateList <int64_t >(
306+ memory_manager_->method_allocator ()->allocateList <int64_t >(
306307 items->size ());
307308
308309 // initialize boxed list
@@ -452,9 +453,9 @@ Error Method::resolve_operator(
452453 populateOperatorName (op, kTempBufferSizeForName , operator_name);
453454
454455 // resolve tensor meta
455- auto runtime_allocator = memory_manager_->get_runtime_allocator ();
456+ auto method_allocator = memory_manager_->method_allocator ();
456457 TensorMeta* meta =
457- ET_ALLOCATE_LIST_OR_RETURN_ERROR (runtime_allocator , TensorMeta, n_args);
458+ ET_ALLOCATE_LIST_OR_RETURN_ERROR (method_allocator , TensorMeta, n_args);
458459 size_t count = 0 ;
459460 for (size_t i = 0 ; i < n_args; i++) {
460461 EValue* eval = args[i];
@@ -463,7 +464,7 @@ Error Method::resolve_operator(
463464 auto tensor = eval->toTensor ();
464465 meta[count].dtype_ = tensor.scalar_type ();
465466 exec_aten::DimOrderType* dim_order_ptr = ET_ALLOCATE_LIST_OR_RETURN_ERROR (
466- runtime_allocator , exec_aten::DimOrderType, tensor.dim ());
467+ method_allocator , exec_aten::DimOrderType, tensor.dim ());
467468 size_t size = tensor.dim ();
468469 Error err = get_dim_order (tensor, dim_order_ptr, size);
469470 ET_CHECK_OR_RETURN_ERROR (
@@ -514,7 +515,7 @@ Error Method::init(executorch_flatbuffer::ExecutionPlan* s_plan) {
514515 init_state_ =
515516 InitializationState::InitializationFailed; // Until proven otherwise
516517 serialization_plan_ = s_plan;
517- auto runtime_allocator = memory_manager_->get_runtime_allocator ();
518+ auto method_allocator = memory_manager_->method_allocator ();
518519
519520 {
520521 // Parse the elements of the values_ array.
@@ -530,7 +531,7 @@ Error Method::init(executorch_flatbuffer::ExecutionPlan* s_plan) {
530531 ET_CHECK (delegates != nullptr );
531532 size_t n_delegate = delegates->size ();
532533 delegates_ = ET_ALLOCATE_LIST_OR_RETURN_ERROR (
533- runtime_allocator , BackendDelegate, n_delegate);
534+ method_allocator , BackendDelegate, n_delegate);
534535
535536 // n_delegate_ counts the number of successfully-initialized delegates for
536537 // ~Method() to clean up, and is incremented at the bottom of the loop. This
@@ -539,7 +540,7 @@ Error Method::init(executorch_flatbuffer::ExecutionPlan* s_plan) {
539540
540541 for (size_t i = 0 ; i < n_delegate; ++i) {
541542 const auto & delegate = *delegates->Get (i);
542- BackendInitContext backend_init_context (runtime_allocator );
543+ BackendInitContext backend_init_context (method_allocator );
543544 Error err = BackendDelegate::Init (
544545 delegate, program_, backend_init_context, &delegates_[i]);
545546 if (err != Error::Ok) {
@@ -559,15 +560,15 @@ Error Method::init(executorch_flatbuffer::ExecutionPlan* s_plan) {
559560 n_chains_ = chains->size ();
560561
561562 chains_ =
562- ET_ALLOCATE_LIST_OR_RETURN_ERROR (runtime_allocator , Chain, n_chains_);
563+ ET_ALLOCATE_LIST_OR_RETURN_ERROR (method_allocator , Chain, n_chains_);
563564 int32_t num_instructions_missing_op = 0 ;
564565 for (size_t i = 0 ; i < n_chains_; ++i) {
565566 auto s_chain = chains->Get (i);
566567 auto num_instructions = s_chain->instructions ()->size ();
567568 auto chain_instruction_kernels = ET_ALLOCATE_LIST_OR_RETURN_ERROR (
568- runtime_allocator , OpFunction, num_instructions);
569+ method_allocator , OpFunction, num_instructions);
569570 auto chain_instruction_arg_lists = ET_ALLOCATE_LIST_OR_RETURN_ERROR (
570- runtime_allocator , InstructionArgs, num_instructions);
571+ method_allocator , InstructionArgs, num_instructions);
571572
572573 // Set up the argument lists ahead of time and store pointers to them to
573574 // use when the instructions are called
@@ -579,7 +580,7 @@ Error Method::init(executorch_flatbuffer::ExecutionPlan* s_plan) {
579580 const auto arg_idxs =
580581 instruction->instr_args_as_KernelCall ()->args ();
581582 auto res = gen_instruction_arguments (
582- runtime_allocator , values_, arg_idxs->size (), arg_idxs->data ());
583+ method_allocator , values_, arg_idxs->size (), arg_idxs->data ());
583584 if (!res.ok ()) {
584585 return res.error ();
585586 }
@@ -600,7 +601,7 @@ Error Method::init(executorch_flatbuffer::ExecutionPlan* s_plan) {
600601 const auto arg_idxs =
601602 instruction->instr_args_as_DelegateCall ()->args ();
602603 auto res = gen_instruction_arguments (
603- runtime_allocator , values_, arg_idxs->size (), arg_idxs->data ());
604+ method_allocator , values_, arg_idxs->size (), arg_idxs->data ());
604605 if (!res.ok ()) {
605606 return res.error ();
606607 }
0 commit comments