@@ -115,7 +115,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
115
115
ArrayRef<CompileSpec> compile_specs) const override {
116
116
ET_LOG (Info, " EthosUBackend::init %p" , processed->data ());
117
117
118
- char * data = ( char *) processed->data ();
118
+ const char * data = static_cast < const char *>( processed->data () );
119
119
size_t size = processed->size ();
120
120
121
121
// Verify format of vela_bin
@@ -160,15 +160,17 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
160
160
// we might do it).
161
161
EthosUBackendExecuteCallbacks CollectArm_CPU_Cycles;
162
162
163
- ExecutionHandle* execution_handle = (ExecutionHandle*)input_handle;
163
+ ExecutionHandle* execution_handle =
164
+ static_cast <ExecutionHandle*>(input_handle);
164
165
VelaHandles handles;
165
166
166
167
// Command stream - we know at this point it's aligned
167
168
EXECUTORCH_PROF_START (
168
169
event_tracer,
169
170
event_tracer_local_scope,
170
171
" +EthosUBackend::execute()processed_data" );
171
- char * data = (char *)execution_handle->processed ->data ();
172
+ const char * data =
173
+ static_cast <const char *>(execution_handle->processed ->data ());
172
174
EXECUTORCH_PROF_END (event_tracer, event_tracer_local_scope);
173
175
174
176
ET_LOG (Debug, " EthosUBackend::execute %p" , data);
@@ -256,7 +258,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
256
258
handles.inputs ->io [i].elem_size == 2 ;
257
259
258
260
// Select a compatible copy routine
259
- if (both_char and permuted_input_shape) {
261
+ if (both_char && permuted_input_shape) {
260
262
EXECUTORCH_PROF_SCOPE (
261
263
event_tracer,
262
264
" +EthosUBackend::execute()handles.input.permute_CHW_to_HWC()" );
@@ -267,7 +269,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
267
269
tensor_in.size (1 ),
268
270
tensor_in.size (2 ),
269
271
tensor_in.size (3 ));
270
- } else if (both_char or both_int or both_short) {
272
+ } else if (both_char || both_int || both_short) {
271
273
EXECUTORCH_PROF_SCOPE (
272
274
event_tracer, " +EthosUBackend::execute()handles.input.memcpy()" );
273
275
// Sizes match and elt size matches so memcpy
@@ -322,7 +324,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
322
324
event_tracer, event_tracer_local_scope, " +EthosUBackend::execute()NPU" );
323
325
result = ethosu_invoke_v3 (
324
326
driver.get (),
325
- ( void *) handles.cmd_data ,
327
+ static_cast < const void *>( handles.cmd_data ) ,
326
328
handles.cmd_data_size ,
327
329
bases,
328
330
bases_size,
@@ -357,13 +359,14 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
357
359
bool permuted_output_shape;
358
360
ET_CHECK_OK_OR_RETURN_ERROR (check_requires_permute (
359
361
i, tensor_out, &handles.outputs ->io [i], &permuted_output_shape));
360
- if (tensor_out.scalar_type () == ScalarType::Char and
362
+ if (tensor_out.scalar_type () == ScalarType::Char &&
361
363
permuted_output_shape) {
362
364
EXECUTORCH_PROF_SCOPE (
363
365
event_tracer,
364
366
" +EthosUBackend::execute()handles.output.permute_HWC_to_CHW()" );
365
367
366
- char * output_address = (char *)output_addr;
368
+ const char * output_address = static_cast <const char *>(output_addr);
369
+
367
370
permute_HWC_to_CHW (
368
371
output_address,
369
372
tensor_out.mutable_data_ptr <char >(),
@@ -375,10 +378,11 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
375
378
event_tracer, " +EthosUBackend::execute()handles.output.move()" );
376
379
for (int j = 0 ; j < tensor_out.numel (); j++) {
377
380
if (tensor_out.scalar_type () == ScalarType::Char) {
378
- char * output_address = ( char *) output_addr;
381
+ const char * output_address = static_cast < const char *>( output_addr) ;
379
382
tensor_out.mutable_data_ptr <char >()[j] = output_address[j];
380
383
} else {
381
- int * output_address = (int *)output_addr;
384
+ const int * output_address =
385
+ reinterpret_cast <const int *>(output_addr);
382
386
tensor_out.mutable_data_ptr <int >()[j] = output_address[j];
383
387
}
384
388
}
@@ -435,7 +439,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
435
439
return Error::Ok;
436
440
}
437
441
438
- void permute_CHW_to_HWC (char * input, char * output, int C, int H, int W)
442
+ void permute_CHW_to_HWC (const char * input, char * output, int C, int H, int W)
439
443
const {
440
444
for (int i = 0 ; i != H * W; ++i) {
441
445
for (int j = 0 ; j < C; ++j) {
@@ -444,7 +448,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
444
448
}
445
449
}
446
450
447
- void permute_HWC_to_CHW (char * input, char * output, int C, int H, int W)
451
+ void permute_HWC_to_CHW (const char * input, char * output, int C, int H, int W)
448
452
const {
449
453
for (int i = 0 ; i != H * W; ++i) {
450
454
for (int j = 0 ; j < C; ++j) {
0 commit comments