Skip to content

Commit 4e80cad

Browse files
authored
Arm backend: Allocate buffers with alignment (#13412)
Ethos-u driver needs 16 bit alignment for command and scratch buffers. Signed-off-by: Erik Lundell <[email protected]>
1 parent 36d342c commit 4e80cad

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

backends/arm/runtime/EthosUBackend.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
192192
// Use a temporary allocator for the intermediate tensors of the
193193
// computation. The allocator is released in runtime/executor/method.cpp at
194194
// the end of the execution of the Ethos-U custom delegate
195-
char* ethosu_scratch =
196-
static_cast<char*>(temp_allocator->allocate(handles.scratch_data_size));
195+
// Ethos-U driver requires 16 bit alignment.
196+
char* ethosu_scratch = static_cast<char*>(
197+
temp_allocator->allocate(handles.scratch_data_size, 16UL));
197198
if (ethosu_scratch == nullptr) {
198199
ET_LOG(
199200
Error,

examples/arm/executor_runner/arm_executor_runner.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,8 +521,9 @@ void runner_init(
521521
ET_LOG(Info, "Setting up planned buffer %zu, size %zu.", id, buffer_size);
522522

523523
/* Move to it's own allocator when MemoryPlanner is in place. */
524-
uint8_t* buffer =
525-
reinterpret_cast<uint8_t*>(ctx.method_allocator->allocate(buffer_size));
524+
/* Ethos-U driver requires 16 bit alignment. */
525+
uint8_t* buffer = reinterpret_cast<uint8_t*>(
526+
ctx.method_allocator->allocate(buffer_size, 16UL));
526527
ET_CHECK_MSG(
527528
buffer != nullptr,
528529
"Could not allocate memory for memory planned buffer size %zu",

0 commit comments

Comments
 (0)