Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backends/cortex_m/passes/aten_to_cortex_m_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ def _get_permute_replacement(
) -> DialectNodeSpec | None:
del dialect_pass
input_tensor = _get_input_tensor_data(node)
if input_tensor.dtype != torch.int8:
if input_tensor.dtype != torch.int8 or not 1 <= input_tensor.dim() <= 4:
return None
return _transpose_spec(node, input_tensor)

Expand Down
19 changes: 19 additions & 0 deletions backends/cortex_m/test/ops/test_transpose.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
"executorch_exir_dialects_edge__ops_cortex_m_dequantize_per_tensor_default": 1,
}

RANK5_OPS_AFTER_PASSES = {
"executorch_exir_dialects_edge__ops_cortex_m_quantize_per_tensor_default": 1,
"executorch_exir_dialects_edge__ops_aten_permute_copy_default": 1,
"executorch_exir_dialects_edge__ops_cortex_m_dequantize_per_tensor_default": 1,
}


class CortexMPermute(torch.nn.Module):
ops_before_transforms = OPS_BEFORE_PASSES
Expand Down Expand Up @@ -98,6 +104,19 @@ def test_dialect_transpose(test_case, cortex_m_target):
)


def test_dialect_rank5_permute_stays_portable(cortex_m_target):
tester = CortexMTester(
CortexMPermute((0, 2, 1, 4, 3)),
(ramp_tensor(-1.0, 1.0, (1, 2, 3, 4, 5)),),
target_config=cortex_m_target,
)
tester.test_dialect(
OPS_BEFORE_PASSES,
RANK5_OPS_AFTER_PASSES,
qtol=1,
)


@parametrize("test_case", test_cases)
def test_implementation_transpose(test_case, cortex_m_target):
tester = CortexMTester(
Expand Down
Loading