@@ -234,12 +234,17 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
234234 supported |=
235235 (tensor_in.scalar_type () == ScalarType::Short and
236236 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 );
237241 if (!supported) {
238242 ET_LOG (
239243 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 " ,
241245 i,
242- executorch::runtime::toString (tensor_in.scalar_type ()));
246+ executorch::runtime::toString (tensor_in.scalar_type ()),
247+ handles.inputs ->io [i].elem_size );
243248 return Error::InvalidProgram;
244249 }
245250 supported = executorch::runtime::is_contiguous_dim_order (
@@ -257,15 +262,17 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
257262 bool permuted_input_shape;
258263 ET_CHECK_OK_OR_RETURN_ERROR (check_requires_permute (
259264 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 &&
263266 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 &&
265270 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 );
266273
267274 // Select a compatible copy routine
268- if (both_char && permuted_input_shape) {
275+ if (( both_char || both_bool) && permuted_input_shape) {
269276 EXECUTORCH_PROF_SCOPE (
270277 event_tracer,
271278 " +EthosUBackend::execute()handles.input.permute_CHW_to_HWC()" );
@@ -276,7 +283,7 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
276283 tensor_in.size (1 ),
277284 tensor_in.size (2 ),
278285 tensor_in.size (3 ));
279- } else if (both_char || both_int || both_short) {
286+ } else if (both_char || both_int || both_short || both_bool ) {
280287 EXECUTORCH_PROF_SCOPE (
281288 event_tracer, " +EthosUBackend::execute()handles.input.memcpy()" );
282289 // Sizes match and elt size matches so memcpy
@@ -363,7 +370,9 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
363370 bool permuted_output_shape;
364371 ET_CHECK_OK_OR_RETURN_ERROR (check_requires_permute (
365372 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) &&
367376 permuted_output_shape) {
368377 EXECUTORCH_PROF_SCOPE (
369378 event_tracer,
@@ -379,17 +388,12 @@ class EthosUBackend final : public ::executorch::runtime::BackendInterface {
379388 tensor_out.size (3 ));
380389 } else {
381390 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 ());
393397 }
394398 }
395399 if (tensor_dim != io_dim) {
0 commit comments