Skip to content

I want to understand the allocations made on STM32s by Executorch #9491

Open
@ChristophKarlHeck

Description

@ChristophKarlHeck

📚 The doc issue

@tarun292, @kimishpatel, yesterday's issue was closed, so I opened a new one.
So here is the continuing of the #9447

There are two sections in the exeutor_runner.cpp that make heap allocations:

  1. m_method_allocator_pool = (uint8_t*)malloc(m_allocator_pool_size);
  2. planned_buffers.push_back(std::make_unique<uint8_t[]>(buffer_size));

The size for the second one is precise (33168). I get it from the execution plan.

executorch_program: exir.ExecutorchProgramManager = edge_program.to_executorch(
    ExecutorchBackendConfig(
        passes=[],  # User-defined passes
    )
)
print(executorch_program.executorch_program.execution_plan[0].non_const_buffer_sizes)

The first one is unclear yet. Since the CNN execution on the STM32 works with a m_allocator_pool_size of 8192 but not with a size of 4096, allocating 33168bytes is pointless since I want to save as much SRAM as possible.
I assume the method size is between 4096 and 8192, but where do I get the exact size? Since the error I get when I set `m_allocator_pool_size to 4096 is:

E executorch:memory_allocator.h:87] Memory allocation failed: 48B requested (adjusted for alignment), 44B available
I executorch:ModelExecutor.cpp:283] Loading of method forward failed with status 0x21

It happens in this code section:

Result<torch::executor::Method> method = program->load_method(method_name, &memory_manager);
if (!method.ok()) {
	ET_LOG(
		Info,
		"Loading of method %s failed with status 0x%" PRIx32,
		method_name,
		method.error());
}

Thank you for being so helpful in advance!
Christoph

cc @larryliu0820 @JacobSzwejbka

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: runtimeIssues related to the core runtime and code under runtime/triagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    • Status

      To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions