diff --git a/backends/arm/runtime/EthosUBackend_Cortex_M.cpp b/backends/arm/runtime/EthosUBackend_Cortex_M.cpp index 11d5360b123..9a810ce706e 100644 --- a/backends/arm/runtime/EthosUBackend_Cortex_M.cpp +++ b/backends/arm/runtime/EthosUBackend_Cortex_M.cpp @@ -17,6 +17,24 @@ #include +// 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 #include @@ -48,12 +66,20 @@ Error platform_execute( int output_count, Span 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_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; } diff --git a/backends/arm/runtime/targets.bzl b/backends/arm/runtime/targets.bzl index 29455f0e657..42df03fb58b 100644 --- a/backends/arm/runtime/targets.bzl +++ b/backends/arm/runtime/targets.bzl @@ -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(