Skip to content

Commit 5768cb4

Browse files
committed
Arm backend: Test temp memory allocation return code in backend
Signed-off-by: Zingo Andersen <[email protected]> Change-Id: I150ab46e76a6b57d83ec74d47d8194a64a058ada
1 parent a1dec07 commit 5768cb4

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

backends/arm/runtime/EthosUBackend.cpp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
113113
BackendInitContext& context,
114114
FreeableBuffer* processed,
115115
ArrayRef<CompileSpec> compile_specs) const override {
116-
ET_LOG(Info, "EthosUBackend::init %p", processed->data());
116+
ET_LOG(Info, "data:%p", processed->data());
117117

118118
const char* data = static_cast<const char*>(processed->data());
119119
size_t size = processed->size();
@@ -173,7 +173,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
173173
static_cast<const char*>(execution_handle->processed->data());
174174
EXECUTORCH_PROF_END(event_tracer, event_tracer_local_scope);
175175

176-
ET_LOG(Debug, "EthosUBackend::execute %p", data);
176+
ET_LOG(Debug, "data:%p", data);
177177

178178
EXECUTORCH_PROF_START(
179179
event_tracer,
@@ -182,7 +182,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
182182
// Read key sections from the vela_bin_stream
183183
if (vela_bin_read(data, &handles, execution_handle->processed->size()) ==
184184
false) {
185-
ET_LOG(Error, "EthosUBackend::vela_read: error, invalid binary layout");
185+
ET_LOG(Error, "vela_read: error, invalid binary layout");
186186
return Error::InvalidProgram;
187187
}
188188
EXECUTORCH_PROF_END(event_tracer, event_tracer_local_scope);
@@ -193,9 +193,16 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
193193
// the end of the execution of the Ethos-U custom delegate
194194
char* ethosu_scratch =
195195
static_cast<char*>(temp_allocator->allocate(handles.scratch_data_size));
196+
if (ethosu_scratch == nullptr) {
197+
ET_LOG(
198+
Error,
199+
"Failed to allocate scratch buffer of %zu bytes from temp_allocator",
200+
handles.scratch_data_size);
201+
return Error::MemoryAllocationFailed;
202+
}
196203
ET_LOG(
197204
Debug,
198-
"EthosUBackend::execute: Running program data:\n cmd %p %zu\n weight %p %zu\n scratch %p %zu\n fast scratch %p %zu\n",
205+
"Running program data:\n cmd %p %zu\n weight %p %zu\n scratch %p %zu\n fast scratch %p %zu\n",
199206
handles.cmd_data,
200207
handles.cmd_data_size,
201208
handles.weight_data,
@@ -301,7 +308,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
301308
std::unique_ptr<ethosu_driver, decltype(&ethosu_release_driver)>(
302309
ethosu_reserve_driver(), ethosu_release_driver);
303310
if (driver == NULL) {
304-
ET_LOG(Error, "EthosUBackend::execute: ethosu_reserve_driver failed");
311+
ET_LOG(Error, "ethosu_reserve_driver failed");
305312
return Error::InvalidState;
306313
}
307314

@@ -333,10 +340,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
333340
EXECUTORCH_PROF_END(event_tracer, event_tracer_local_scope);
334341

335342
if (result != 0) {
336-
ET_LOG(
337-
Error,
338-
"EthosUBackend::execute: Ethos-U invocation failed error (%d)",
339-
result);
343+
ET_LOG(Error, "Ethos-U invocation failed error (%d)", result);
340344
return Error::InvalidProgram;
341345
}
342346
int tensor_dim = 0, io_dim = 0;

examples/arm/executor_runner/arm_executor_runner.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,13 @@ void et_pal_emit_log_message(
201201
const char* message,
202202
ET_UNUSED size_t length) {
203203
fprintf(
204-
stderr, "%c [executorch:%s:%zu] %s\n", level, filename, line, message);
204+
stderr,
205+
"%c [executorch:%s:%zu %s()] %s\n",
206+
level,
207+
filename,
208+
line,
209+
function,
210+
message);
205211
}
206212

207213
/**

0 commit comments

Comments
 (0)