@@ -115,7 +115,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
115115 ArrayRef<CompileSpec> compile_specs) const override {
116116 ET_LOG (Info, " EthosUBackend::init %p" , processed->data ());
117117
118- char * data = ( char *) processed->data ();
118+ const char * data = static_cast < const char *>( processed->data () );
119119 size_t size = processed->size ();
120120
121121 // Verify format of vela_bin
@@ -160,15 +160,17 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
160160 // we might do it).
161161 EthosUBackendExecuteCallbacks CollectArm_CPU_Cycles;
162162
163- ExecutionHandle* execution_handle = (ExecutionHandle*)input_handle;
163+ ExecutionHandle* execution_handle =
164+ static_cast <ExecutionHandle*>(input_handle);
164165 VelaHandles handles;
165166
166167 // Command stream - we know at this point it's aligned
167168 EXECUTORCH_PROF_START (
168169 event_tracer,
169170 event_tracer_local_scope,
170171 " +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 ());
172174 EXECUTORCH_PROF_END (event_tracer, event_tracer_local_scope);
173175
174176 ET_LOG (Debug, " EthosUBackend::execute %p" , data);
@@ -256,7 +258,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
256258 handles.inputs ->io [i].elem_size == 2 ;
257259
258260 // Select a compatible copy routine
259- if (both_char and permuted_input_shape) {
261+ if (both_char && permuted_input_shape) {
260262 EXECUTORCH_PROF_SCOPE (
261263 event_tracer,
262264 " +EthosUBackend::execute()handles.input.permute_CHW_to_HWC()" );
@@ -267,7 +269,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
267269 tensor_in.size (1 ),
268270 tensor_in.size (2 ),
269271 tensor_in.size (3 ));
270- } else if (both_char or both_int or both_short) {
272+ } else if (both_char || both_int || both_short) {
271273 EXECUTORCH_PROF_SCOPE (
272274 event_tracer, " +EthosUBackend::execute()handles.input.memcpy()" );
273275 // Sizes match and elt size matches so memcpy
@@ -322,7 +324,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
322324 event_tracer, event_tracer_local_scope, " +EthosUBackend::execute()NPU" );
323325 result = ethosu_invoke_v3 (
324326 driver.get (),
325- ( void *) handles.cmd_data ,
327+ static_cast < const void *>( handles.cmd_data ) ,
326328 handles.cmd_data_size ,
327329 bases,
328330 bases_size,
@@ -357,13 +359,14 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
357359 bool permuted_output_shape;
358360 ET_CHECK_OK_OR_RETURN_ERROR (check_requires_permute (
359361 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 &&
361363 permuted_output_shape) {
362364 EXECUTORCH_PROF_SCOPE (
363365 event_tracer,
364366 " +EthosUBackend::execute()handles.output.permute_HWC_to_CHW()" );
365367
366- char * output_address = (char *)output_addr;
368+ const char * output_address = static_cast <const char *>(output_addr);
369+
367370 permute_HWC_to_CHW (
368371 output_address,
369372 tensor_out.mutable_data_ptr <char >(),
@@ -375,10 +378,11 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
375378 event_tracer, " +EthosUBackend::execute()handles.output.move()" );
376379 for (int j = 0 ; j < tensor_out.numel (); j++) {
377380 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) ;
379382 tensor_out.mutable_data_ptr <char >()[j] = output_address[j];
380383 } else {
381- int * output_address = (int *)output_addr;
384+ const int * output_address =
385+ reinterpret_cast <const int *>(output_addr);
382386 tensor_out.mutable_data_ptr <int >()[j] = output_address[j];
383387 }
384388 }
@@ -435,7 +439,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
435439 return Error::Ok;
436440 }
437441
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)
439443 const {
440444 for (int i = 0 ; i != H * W; ++i) {
441445 for (int j = 0 ; j < C; ++j) {
@@ -444,7 +448,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
444448 }
445449 }
446450
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)
448452 const {
449453 for (int i = 0 ; i != H * W; ++i) {
450454 for (int j = 0 ; j < C; ++j) {
0 commit comments