File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,13 @@ void __attribute__((weak)) EthosUBackend_execute_begin() {}
8383void __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+
8693class 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 ;
You can’t perform that action at this time.
0 commit comments