@@ -234,12 +234,17 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
234
234
supported |=
235
235
(tensor_in.scalar_type () == ScalarType::Short and
236
236
handles.inputs ->io [i].elem_size == 2 );
237
+ // bool (IOQDQ pass prepared networks)
238
+ supported |=
239
+ (tensor_in.scalar_type () == ScalarType::Bool and
240
+ handles.inputs ->io [i].elem_size == 1 );
237
241
if (!supported) {
238
242
ET_LOG (
239
243
Error,
240
- " Input %d expected Integer (4 byte) or Char (1 byte) integer inputs, got ScalarType id %s" ,
244
+ " Input %d expected Integer (4 byte), Char (1 byte) or Bool (1 byte) integer inputs, got ScalarType id %s size %d " ,
241
245
i,
242
- executorch::runtime::toString (tensor_in.scalar_type ()));
246
+ executorch::runtime::toString (tensor_in.scalar_type ()),
247
+ handles.inputs ->io [i].elem_size );
243
248
return Error::InvalidProgram;
244
249
}
245
250
supported = executorch::runtime::is_contiguous_dim_order (
@@ -257,15 +262,17 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
257
262
bool permuted_input_shape;
258
263
ET_CHECK_OK_OR_RETURN_ERROR (check_requires_permute (
259
264
i, tensor_in, &handles.inputs ->io [i], &permuted_input_shape));
260
- bool both_char = tensor_in.scalar_type () == ScalarType::Char and
261
- handles.inputs ->io [i].elem_size == 1 ;
262
- bool both_int = tensor_in.scalar_type () == ScalarType::Int and
265
+ bool both_int = tensor_in.scalar_type () == ScalarType::Int &&
263
266
handles.inputs ->io [i].elem_size == 4 ;
264
- bool both_short = tensor_in.scalar_type () == ScalarType::Short and
267
+ bool both_char = tensor_in.scalar_type () == ScalarType::Char &&
268
+ handles.inputs ->io [i].elem_size == 1 ;
269
+ bool both_short = tensor_in.scalar_type () == ScalarType::Short &&
265
270
handles.inputs ->io [i].elem_size == 2 ;
271
+ bool both_bool = tensor_in.scalar_type () == ScalarType::Bool &&
272
+ (handles.inputs ->io [i].elem_size == 1 );
266
273
267
274
// Select a compatible copy routine
268
- if (both_char && permuted_input_shape) {
275
+ if (( both_char || both_bool) && permuted_input_shape) {
269
276
EXECUTORCH_PROF_SCOPE (
270
277
event_tracer,
271
278
" +EthosUBackend::execute()handles.input.permute_CHW_to_HWC()" );
@@ -276,7 +283,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
276
283
tensor_in.size (1 ),
277
284
tensor_in.size (2 ),
278
285
tensor_in.size (3 ));
279
- } else if (both_char || both_int || both_short) {
286
+ } else if (both_char || both_int || both_short || both_bool ) {
280
287
EXECUTORCH_PROF_SCOPE (
281
288
event_tracer, " +EthosUBackend::execute()handles.input.memcpy()" );
282
289
// Sizes match and elt size matches so memcpy
@@ -363,7 +370,9 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
363
370
bool permuted_output_shape;
364
371
ET_CHECK_OK_OR_RETURN_ERROR (check_requires_permute (
365
372
i, tensor_out, &handles.outputs ->io [i], &permuted_output_shape));
366
- if (tensor_out.scalar_type () == ScalarType::Char &&
373
+
374
+ if ((tensor_out.scalar_type () == ScalarType::Char ||
375
+ tensor_out.scalar_type () == ScalarType::Bool) &&
367
376
permuted_output_shape) {
368
377
EXECUTORCH_PROF_SCOPE (
369
378
event_tracer,
@@ -379,17 +388,12 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
379
388
tensor_out.size (3 ));
380
389
} else {
381
390
EXECUTORCH_PROF_SCOPE (
382
- event_tracer, " +EthosUBackend::execute()handles.output.move()" );
383
- for (int j = 0 ; j < tensor_out.numel (); j++) {
384
- if (tensor_out.scalar_type () == ScalarType::Char) {
385
- const char * output_address = static_cast <const char *>(output_addr);
386
- tensor_out.mutable_data_ptr <char >()[j] = output_address[j];
387
- } else {
388
- const int * output_address =
389
- reinterpret_cast <const int *>(output_addr);
390
- tensor_out.mutable_data_ptr <int >()[j] = output_address[j];
391
- }
392
- }
391
+ event_tracer, " +EthosUBackend::execute()handles.output.memcpy()" );
392
+
393
+ memcpy (
394
+ tensor_out.mutable_data_ptr <char >(),
395
+ static_cast <const char *>(output_addr),
396
+ tensor_out.nbytes ());
393
397
}
394
398
}
395
399
if (tensor_dim != io_dim) {
0 commit comments