From 3b8a84d08e2f5ce4b2d283b45c2e3f4f15b0a850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5ns=20Nilsson?= Date: Mon, 6 Oct 2025 20:05:17 +0200 Subject: [PATCH] Arm backend: Fix Arm tester issue for inplace ops (#14625) Deep-copying the input avoids it getting mutated by the first reference run. (cherry picked from commit b6bc421f2c01c38cb8a300a1cee6799151cf7818) --- backends/arm/test/tester/arm_tester.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/backends/arm/test/tester/arm_tester.py b/backends/arm/test/tester/arm_tester.py index bb249644c47..62a12676c83 100644 --- a/backends/arm/test/tester/arm_tester.py +++ b/backends/arm/test/tester/arm_tester.py @@ -458,6 +458,10 @@ def run_method_and_compare_outputs( for run_iteration in range(num_runs): reference_input = inputs if inputs else next(self.generate_random_inputs()) + # Avoid issues with inplace operators + test_input = copy.deepcopy(reference_input) + original_input = copy.deepcopy(reference_input) + input_shapes = [ generated_input.shape if hasattr(generated_input, "shape") else (1,) for generated_input in reference_input @@ -472,16 +476,16 @@ def run_method_and_compare_outputs( # Run exported module directly test_outputs, _ = pytree.tree_flatten( self._calculate_reference_output( - exported_program.module(), reference_input + exported_program.module(), test_input ) ) else: # Run lowered model with target test_outputs, _ = pytree.tree_flatten( - test_stage.run_artifact(reference_input) + test_stage.run_artifact(test_input) ) - logger.info(f"\n Input: {reference_input}") + logger.info(f"\n Input: {original_input}") logger.info(f"\n Ref output: {reference_outputs}") logger.info(f"\nTest output: {test_outputs}")