Skip to content

Commit e79bd63

Browse files
authored
Arm backend: Disallow bool when partitioning for Ethos-U55 (pytorch#18095)
It is not supported. Signed-off-by: Erik Lundell <erik.lundell@arm.com>
1 parent 66b5448 commit e79bd63

2 files changed

Lines changed: 23 additions & 21 deletions

File tree

‎backends/arm/operator_support/tosa_supported_operators.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ def tosa_support_factory(
297297
disallowed_dtypes = [torch.float64]
298298
if not tosa_spec.support_extension("bf16"):
299299
disallowed_dtypes.append(torch.bfloat16)
300+
if tosa_spec.is_U55_subset:
301+
disallowed_dtypes.append(torch.bool)
300302
negative_checks.append(
301303
CheckDtypeInputsAndOutputs(
302304
exported_program, reporter, disallowed_dtypes, tosa_spec

‎backends/arm/test/ops/test_bitwise.py‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def test_bitwise_and_scalar_tosa_INT(test_data: input_t2):
230230

231231

232232
@common.parametrize("test_data", And().test_data_non_bool)
233-
def test_bitwise_and_tensor_u55_INT(test_data: input_t2):
233+
def test_bitwise_and_tensor_u55_INT_not_delegated(test_data: input_t2):
234234
# Tests that we don't delegate these ops since they are not supported on U55.
235235
pipeline = OpNotSupportedPipeline[input_t2](
236236
And(),
@@ -243,16 +243,16 @@ def test_bitwise_and_tensor_u55_INT(test_data: input_t2):
243243

244244

245245
@common.parametrize("test_data", AndScalar.test_data)
246-
def test_bitwise_and_scalar_u55_INT(test_data: input_t2):
247-
# There will be one full op which will be delegated.
248-
num_delegates = 1
249-
num_exir = 0
246+
def test_bitwise_and_scalar_u55_INT_not_delegated(test_data: input_t2):
247+
# There will be one full op which will be delegated, unless it outputs boolean.
248+
test_input = test_data()
249+
num_delegates = 0 if test_input[0].dtype == torch.bool else 1
250250
pipeline = OpNotSupportedPipeline[input_t2](
251251
AndScalar(),
252-
test_data(),
252+
test_input,
253253
{
254254
AndScalar.exir_op: 1,
255-
"executorch_exir_dialects_edge__ops_aten_full_default": num_exir,
255+
"executorch_exir_dialects_edge__ops_aten_full_default": 1 - num_delegates,
256256
},
257257
num_delegates,
258258
quantize=True,
@@ -437,7 +437,7 @@ def test_bitwise_xor_scalar_tosa_INT(test_data: input_t2):
437437

438438

439439
@common.parametrize("test_data", Xor().test_data_non_bool)
440-
def test_bitwise_xor_tensor_u55_INT(test_data: input_t2):
440+
def test_bitwise_xor_tensor_u55_INT_not_delegated(test_data: input_t2):
441441
# Tests that we don't delegate these ops since they are not supported on U55.
442442
pipeline = OpNotSupportedPipeline[input_t2](
443443
Xor(),
@@ -450,16 +450,16 @@ def test_bitwise_xor_tensor_u55_INT(test_data: input_t2):
450450

451451

452452
@common.parametrize("test_data", XorScalar.test_data)
453-
def test_bitwise_xor_scalar_u55_INT(test_data: input_t2):
454-
# There will be one full op which will be delegated.
455-
num_delegates = 1
456-
num_exir = 0
453+
def test_bitwise_xor_scalar_u55_INT_not_delegated(test_data: input_t2):
454+
# There will be one full op which will be delegated, unless it outputs boolean.
455+
test_input = test_data()
456+
num_delegates = 0 if test_input[0].dtype == torch.bool else 1
457457
pipeline = OpNotSupportedPipeline[input_t2](
458458
XorScalar(),
459-
test_data(),
459+
test_input,
460460
{
461461
XorScalar.exir_op: 1,
462-
"executorch_exir_dialects_edge__ops_aten_full_default": num_exir,
462+
"executorch_exir_dialects_edge__ops_aten_full_default": 1 - num_delegates,
463463
},
464464
num_delegates,
465465
quantize=True,
@@ -644,7 +644,7 @@ def test_bitwise_or_scalar_tosa_INT(test_data: input_t2):
644644

645645

646646
@common.parametrize("test_data", Or().test_data_non_bool)
647-
def test_bitwise_or_tensor_u55_INT(test_data: input_t2):
647+
def test_bitwise_or_tensor_u55_INT_not_delegated(test_data: input_t2):
648648
# Tests that we don't delegate these ops since they are not supported on U55.
649649
pipeline = OpNotSupportedPipeline[input_t2](
650650
Or(),
@@ -657,16 +657,16 @@ def test_bitwise_or_tensor_u55_INT(test_data: input_t2):
657657

658658

659659
@common.parametrize("test_data", OrScalar.test_data)
660-
def test_bitwise_or_scalar_u55_INT(test_data: input_t2):
661-
# There will be one full op which will be delegated.
662-
num_delegates = 1
663-
num_exir = 0
660+
def test_bitwise_or_scalar_u55_INT_not_delegated(test_data: input_t2):
661+
# There will be one full op which will be delegated, unless it outputs boolean.
662+
test_input = test_data()
663+
num_delegates = 0 if test_input[0].dtype == torch.bool else 1
664664
pipeline = OpNotSupportedPipeline[input_t2](
665665
OrScalar(),
666-
test_data(),
666+
test_input,
667667
{
668668
OrScalar.exir_op: 1,
669-
"executorch_exir_dialects_edge__ops_aten_full_default": num_exir,
669+
"executorch_exir_dialects_edge__ops_aten_full_default": 1 - num_delegates,
670670
},
671671
num_delegates,
672672
quantize=True,

0 commit comments

Comments
 (0)