Skip to content

Commit 2935153

Browse files
limintangfacebook-github-bot
authored andcommitted
Bug fix in Ethos runtime backend (#9517)
Summary: See the comment in source for explanation. Also change the default MACs for U85 to 256, which is default on FVP SSE-320. Differential Revision: D71658384
1 parent 0dd7e4e commit 2935153

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

backends/arm/runtime/EthosUBackend.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ void __attribute__((weak)) EthosUBackend_execute_begin() {}
8383
void __attribute__((weak)) EthosUBackend_execute_end() {}
8484
}
8585

86+
// If the address is >= 0x80000000, cast to uint64_t signed extends it to 0xFFFFFFFFXXXXXXXX,
87+
// which causes address validity check in Ethos driver to fail. Given Cortex-M is 32-bit, it
88+
// is safe to clear the upper 32 bits after the cast and keep the address valid.
89+
static inline uint64_t cast_address_to_uint64(void* p) {
90+
return (0xFFFFFFFF & reinterpret_cast<uint64_t>(p));
91+
}
92+
8693
class EthosUBackendExecuteCallbacks {
8794
public:
8895
EthosUBackendExecuteCallbacks() {
@@ -282,7 +289,8 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
282289
// constant weight data, then scratch (which contains input and output)
283290
// scratch is written above in this function.
284291
uint64_t bases[2] = {
285-
(uint64_t)handles.weight_data, (uint64_t)handles.scratch_data};
292+
cast_address_to_uint64(handles.weight_data),
293+
cast_address_to_uint64(handles.scratch_data)};
286294
size_t bases_size[2] = {
287295
handles.weight_data_size, handles.scratch_data_size};
288296
int result = 0;

backends/arm/test/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def get_u55_compile_spec(
110110

111111

112112
def get_u85_compile_spec(
113-
macs: int = 128,
113+
macs: int = 256,
114114
system_config="Ethos_U85_SYS_DRAM_Mid",
115115
memory_mode="Shared_Sram",
116116
extra_flags="--output-format=raw",

0 commit comments

Comments
 (0)