Skip to content

Commit bea155f

Browse files
limintangfacebook-github-bot
authored andcommitted
Bug fix in Ethos runtime backend (#9517)
Summary: Cortex-M is 32-bit, so pointer type in the runtime backend is also 32-bit. If the address >= 0x80000000, direct cast to uint64_t treates it as signed integer and signed extends it to 0xFFFFFFFFXXXXXXXX, which causes address validity check in Ethos driver to fail. First cast it to unsigned type uintptr_t then cast to uint64_t avoids this issue. Also change the default MACs in U85 compile spec to 256, which is default on FVP SSE-320. Differential Revision: D71658384
1 parent d980ce0 commit bea155f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

backends/arm/runtime/EthosUBackend.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* ethos-u-core-driver for hardware interaction.
1111
*/
1212

13+
#include <cstdint>
1314
#include <cstring>
1415
#include <memory>
1516

@@ -282,7 +283,8 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
282283
// constant weight data, then scratch (which contains input and output)
283284
// scratch is written above in this function.
284285
uint64_t bases[2] = {
285-
(uint64_t)handles.weight_data, (uint64_t)handles.scratch_data};
286+
static_cast<uint64_t>(reinterpret_cast<uintptr_t>((handles.weight_data))),
287+
static_cast<uint64_t>(reinterpret_cast<uintptr_t>((handles.scratch_data)))};
286288
size_t bases_size[2] = {
287289
handles.weight_data_size, handles.scratch_data_size};
288290
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)