From 9ab9ee2ca5d44a67313b8e5a709ed00097b4c4e1 Mon Sep 17 00:00:00 2001 From: Erik Lundell Date: Mon, 17 Feb 2025 13:34:36 +0100 Subject: [PATCH] Arm: Fix various small issues - Softmax incorrectly set to can_delegate=False in aot_arm_compiler - Incorrect % with rank instead of dim length. Fix test for this. - Remove .dump_artifact():s Signed-off-by: Erik Lundell Change-Id: Ibf790765d61881cc892106e511b2aa156811c874 --- backends/arm/_passes/decompose_select.py | 3 ++- backends/arm/test/ops/test_cat.py | 1 - backends/arm/test/ops/test_select.py | 4 +--- backends/arm/test/ops/test_to_copy.py | 4 +--- examples/arm/aot_arm_compiler.py | 2 +- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/backends/arm/_passes/decompose_select.py b/backends/arm/_passes/decompose_select.py index 5e04668df9a..9a25b7c28ae 100644 --- a/backends/arm/_passes/decompose_select.py +++ b/backends/arm/_passes/decompose_select.py @@ -35,8 +35,9 @@ def call(self, graph_module: torch.fx.GraphModule): input_node, dim, index = node.args rank = len(input_node.meta["val"].size()) + shape = input_node.meta["val"].shape dim = dim % rank if dim < 0 else dim - index = index % rank if index < 0 else index + index = index % shape[dim] if index < 0 else index with graph_module.graph.inserting_before(node): slice_node = create_node( diff --git a/backends/arm/test/ops/test_cat.py b/backends/arm/test/ops/test_cat.py index a1613d1d04b..63423b9e993 100644 --- a/backends/arm/test/ops/test_cat.py +++ b/backends/arm/test/ops/test_cat.py @@ -111,7 +111,6 @@ def _test_cat_ethosu_BI_pipeline( .check(["torch.ops.quantized_decomposed"]) .to_edge() .partition() - .dump_artifact() .check_not(["executorch_exir_dialects_edge__ops_aten_cat_default"]) .check_count({"torch.ops.higher_order.executorch_call_delegate": 1}) .to_executorch() diff --git a/backends/arm/test/ops/test_select.py b/backends/arm/test/ops/test_select.py index b474da573f0..fbeb4ebf9e7 100644 --- a/backends/arm/test/ops/test_select.py +++ b/backends/arm/test/ops/test_select.py @@ -19,7 +19,7 @@ test_data_suite: list[tuple[test_data_t]] = [ # (test_data, dim, index) ((torch.zeros(5, 3, 20), -1, 0),), - ((torch.zeros(5, 3, 20), 0, -1),), + ((torch.rand(5, 3, 20), 0, -1),), ((torch.zeros(5, 3, 20), 0, 4),), ((torch.ones(10, 10, 10), 0, 2),), ((torch.rand(5, 3, 20, 2), 0, 2),), @@ -61,9 +61,7 @@ def _test_select_tosa_MI_pipeline( .check([export_target]) .check_not(["torch.ops.quantized_decomposed"]) .to_edge() - .dump_artifact() .partition() - .dump_artifact() .check_count({"torch.ops.higher_order.executorch_call_delegate": 1}) .to_executorch() .run_method_and_compare_outputs(inputs=test_data) diff --git a/backends/arm/test/ops/test_to_copy.py b/backends/arm/test/ops/test_to_copy.py index 6992ac2f8e6..db3e93fbdc9 100644 --- a/backends/arm/test/ops/test_to_copy.py +++ b/backends/arm/test/ops/test_to_copy.py @@ -1,4 +1,4 @@ -# Copyright 2024 Arm Limited and/or its affiliates. +# Copyright 2024-2025 Arm Limited and/or its affiliates. # All rights reserved. # # This source code is licensed under the BSD-style license found in the @@ -55,9 +55,7 @@ def _test_to_copy_tosa_MI_pipeline( compile_spec=common.get_tosa_compile_spec("TOSA-0.80+MI"), ) .export() - .dump_artifact() .to_edge() - .dump_artifact() .partition() .check_count({"torch.ops.higher_order.executorch_call_delegate": 1}) .to_executorch() diff --git a/examples/arm/aot_arm_compiler.py b/examples/arm/aot_arm_compiler.py index ccd736f7fce..f7f2105b99c 100644 --- a/examples/arm/aot_arm_compiler.py +++ b/examples/arm/aot_arm_compiler.py @@ -185,7 +185,7 @@ def forward(self, x): return z example_input = (torch.ones(2, 2),) - can_delegate = False + can_delegate = True class MultipleOutputsModule(torch.nn.Module):