Skip to content

Arm backend: Test temp memory allocation return code in backend #11814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions backends/arm/runtime/EthosUBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
BackendInitContext& context,
FreeableBuffer* processed,
ArrayRef<CompileSpec> compile_specs) const override {
ET_LOG(Info, "EthosUBackend::init %p", processed->data());
ET_LOG(Info, "data:%p", processed->data());

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

ET_LOG(Debug, "EthosUBackend::execute %p", data);
ET_LOG(Debug, "data:%p", data);

EXECUTORCH_PROF_START(
event_tracer,
Expand All @@ -182,7 +182,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
// Read key sections from the vela_bin_stream
if (vela_bin_read(data, &handles, execution_handle->processed->size()) ==
false) {
ET_LOG(Error, "EthosUBackend::vela_read: error, invalid binary layout");
ET_LOG(Error, "vela_read: error, invalid binary layout");
return Error::InvalidProgram;
}
EXECUTORCH_PROF_END(event_tracer, event_tracer_local_scope);
Expand All @@ -193,9 +193,16 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
// the end of the execution of the Ethos-U custom delegate
char* ethosu_scratch =
static_cast<char*>(temp_allocator->allocate(handles.scratch_data_size));
if (ethosu_scratch == nullptr) {
ET_LOG(
Error,
"Failed to allocate scratch buffer of %zu bytes from temp_allocator",
handles.scratch_data_size);
return Error::MemoryAllocationFailed;
}
ET_LOG(
Debug,
"EthosUBackend::execute: Running program data:\n cmd %p %zu\n weight %p %zu\n scratch %p %zu\n fast scratch %p %zu\n",
"Running program data:\n cmd %p %zu\n weight %p %zu\n scratch %p %zu\n fast scratch %p %zu\n",
handles.cmd_data,
handles.cmd_data_size,
handles.weight_data,
Expand Down Expand Up @@ -301,7 +308,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
std::unique_ptr<ethosu_driver, decltype(&ethosu_release_driver)>(
ethosu_reserve_driver(), ethosu_release_driver);
if (driver == NULL) {
ET_LOG(Error, "EthosUBackend::execute: ethosu_reserve_driver failed");
ET_LOG(Error, "ethosu_reserve_driver failed");
return Error::InvalidState;
}

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

if (result != 0) {
ET_LOG(
Error,
"EthosUBackend::execute: Ethos-U invocation failed error (%d)",
result);
ET_LOG(Error, "Ethos-U invocation failed error (%d)", result);
return Error::InvalidProgram;
}
int tensor_dim = 0, io_dim = 0;
Expand Down
8 changes: 7 additions & 1 deletion examples/arm/executor_runner/arm_executor_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,13 @@ void et_pal_emit_log_message(
const char* message,
ET_UNUSED size_t length) {
fprintf(
stderr, "%c [executorch:%s:%zu] %s\n", level, filename, line, message);
stderr,
"%c [executorch:%s:%zu %s()] %s\n",
level,
filename,
line,
function,
message);
}

/**
Expand Down
Loading