From 8f7cd1b287ff666725efedd6cb9091a66ce5b155 Mon Sep 17 00:00:00 2001 From: Erik Lundell Date: Wed, 13 Aug 2025 12:09:52 +0200 Subject: [PATCH] Arm backend: allocate buffers with aligment ethos-u driver needs 16 bit alignment for command and scratch buffers. Signed-off-by: Erik Lundell Change-Id: I60a41b49da8928865daadd7fae299b83ecc99b2e --- backends/arm/runtime/EthosUBackend.cpp | 5 +++-- examples/arm/executor_runner/arm_executor_runner.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backends/arm/runtime/EthosUBackend.cpp b/backends/arm/runtime/EthosUBackend.cpp index d29c32b02f3..a31c97d817b 100644 --- a/backends/arm/runtime/EthosUBackend.cpp +++ b/backends/arm/runtime/EthosUBackend.cpp @@ -191,8 +191,9 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface { // Use a temporary allocator for the intermediate tensors of the // computation. The allocator is released in runtime/executor/method.cpp at // the end of the execution of the Ethos-U custom delegate - char* ethosu_scratch = - static_cast(temp_allocator->allocate(handles.scratch_data_size)); + // Ethos-U driver requires 16 bit alignment. + char* ethosu_scratch = static_cast( + temp_allocator->allocate(handles.scratch_data_size, 16UL)); if (ethosu_scratch == nullptr) { ET_LOG( Error, diff --git a/examples/arm/executor_runner/arm_executor_runner.cpp b/examples/arm/executor_runner/arm_executor_runner.cpp index 44241421016..0e0e66dd07b 100644 --- a/examples/arm/executor_runner/arm_executor_runner.cpp +++ b/examples/arm/executor_runner/arm_executor_runner.cpp @@ -521,8 +521,9 @@ void runner_init( ET_LOG(Info, "Setting up planned buffer %zu, size %zu.", id, buffer_size); /* Move to it's own allocator when MemoryPlanner is in place. */ - uint8_t* buffer = - reinterpret_cast(ctx.method_allocator->allocate(buffer_size)); + /* Ethos-U driver requires 16 bit alignment. */ + uint8_t* buffer = reinterpret_cast( + ctx.method_allocator->allocate(buffer_size, 16UL)); ET_CHECK_MSG( buffer != nullptr, "Could not allocate memory for memory planned buffer size %zu",