Skip to content
Open
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
30 changes: 28 additions & 2 deletions backends/arm/runtime/EthosUBackend_Cortex_M.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@

#include <ethosu_driver.h>

// Compatibility hooks for multi-device driver / non-multi-device driver code
// When multi-device driver code is available, these declarations are overridden
extern "C" __attribute__((weak)) int ethosu_get_product_config_from_cop_data(
const void*,
const int,
uint32_t* product_out,
uint32_t* log2_macs_out) {
*product_out = 0;
*log2_macs_out = 0;
return 0;
}

extern "C" __attribute__((weak)) struct ethosu_driver* ethosu_reserve_driver_ex(
uint32_t,
uint32_t) {
return ethosu_reserve_driver();
}

#include <executorch/backends/arm/runtime/EthosUBackend_Internal.h>
#include <executorch/runtime/core/error.h>

Expand Down Expand Up @@ -48,12 +66,20 @@ Error platform_execute(
int output_count,
Span<executorch::runtime::EValue*> args,
char* ethosu_scratch) {
// Parse product config from command stream to reserve the correct driver
uint32_t product, log2_macs;
if (ethosu_get_product_config_from_cop_data(
handles.cmd_data, handles.cmd_data_size, &product, &log2_macs) != 0) {
ET_LOG(Error, "Failed to parse product config from command stream");
return Error::InvalidProgram;
}

// Allocate driver handle and synchronously invoke driver
auto driver =
std::unique_ptr<ethosu_driver, decltype(&ethosu_release_driver)>(
ethosu_reserve_driver(), ethosu_release_driver);
ethosu_reserve_driver_ex(product, log2_macs), ethosu_release_driver);
if (driver == nullptr) {
ET_LOG(Error, "ethosu_reserve_driver failed");
ET_LOG(Error, "ethosu_reserve_driver_ex failed");
return Error::InvalidState;
}

Expand Down
2 changes: 1 addition & 1 deletion backends/arm/runtime/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def define_common_targets():
"//executorch/runtime/backend:interface",
":vela_bin_stream",
"//executorch/runtime/core:core",
"fbsource//third-party/ethos-u-core-driver:core_driver",
"fbsource//third-party/ethos-u-core-driver:core_driver_headers_only",
],
)
runtime.cxx_library(
Expand Down
Loading