From f4350de71c27cb6f66d327b326ed7580d94b4408 Mon Sep 17 00:00:00 2001 From: Erik Lundell Date: Mon, 11 May 2026 15:52:32 +0200 Subject: [PATCH 1/3] Arm backend: Dump partition report to file if intermediate dir is given Signed-off-by: Erik Lundell Change-Id: I8d4524ca3edb60164320cf1d9ba34809fab722a3 --- backends/arm/ethosu/partitioner.py | 1 + backends/arm/tosa/partitioner.py | 7 +++++++ backends/arm/vgf/partitioner.py | 1 + 3 files changed, 9 insertions(+) diff --git a/backends/arm/ethosu/partitioner.py b/backends/arm/ethosu/partitioner.py index 4ce5911ec1f..cd7e8926292 100644 --- a/backends/arm/ethosu/partitioner.py +++ b/backends/arm/ethosu/partitioner.py @@ -34,3 +34,4 @@ def __init__( self.additional_checks = additional_checks self.tosa_spec = compile_spec.tosa_spec self._custom_partition_ops: set[torch._ops.OpOverload] = set() + self.intermediate_path = compile_spec._get_intermediate_path() diff --git a/backends/arm/tosa/partitioner.py b/backends/arm/tosa/partitioner.py index 0f4a3c6e550..a98aaae5318 100644 --- a/backends/arm/tosa/partitioner.py +++ b/backends/arm/tosa/partitioner.py @@ -16,6 +16,7 @@ import logging import operator from itertools import count +from pathlib import Path from typing import Callable, cast, List, Optional, Sequence, Tuple import torch @@ -177,6 +178,7 @@ def __init__( self.tosa_spec = compile_spec.tosa_spec self.additional_checks = additional_checks self._custom_partition_ops: set[torch._ops.OpOverload] = set() + self.intermediate_path = compile_spec._get_intermediate_path() def register_custom_partition_op(self, op: torch._ops.OpOverload) -> None: """Register a custom op to be considered supported by this @@ -430,6 +432,11 @@ def partition(self, exported_program: ExportedProgram) -> PartitionResult: partition_tags = {tag: self.delegation_spec for tag in tags} tag_constant_data(exported_program) + if self.intermediate_path is not None and logger.level <= logging.INFO: + file_handler = logging.FileHandler( + Path(self.intermediate_path) / "partition_report.txt" + ) + logger.addHandler(file_handler) logger.info(f"The following nodes were rejected for {self.tosa_spec}:") logger.info("\n" + reporter.get_table_report()) logger.info("(Placeholders and outputs are not included in this list)") diff --git a/backends/arm/vgf/partitioner.py b/backends/arm/vgf/partitioner.py index eea49e8bc03..3810ba750ef 100644 --- a/backends/arm/vgf/partitioner.py +++ b/backends/arm/vgf/partitioner.py @@ -34,3 +34,4 @@ def __init__( self.additional_checks = additional_checks self.tosa_spec = compile_spec.tosa_spec self._custom_partition_ops: set[torch._ops.OpOverload] = set() + self.intermediate_path = compile_spec._get_intermediate_path() From c6c2f374cb381108f6a4d268c27bf2be23e342db Mon Sep 17 00:00:00 2001 From: Erik Lundell Date: Wed, 13 May 2026 16:05:57 +0200 Subject: [PATCH 2/3] Fix test_collate_tests_tosa_INT test The test tested that all files in the collate_tosa dir ended with expected suffix which has two problems: 1) The dir can contain other files 2) The test passes even if the dir is empty Instead, make sure that at least one of the expected files is present. Signed-off-by: Erik Lundell Change-Id: I746f522079c02f056338f7b5c89dc7adf6eec01e --- backends/arm/test/misc/test_debug_feats.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backends/arm/test/misc/test_debug_feats.py b/backends/arm/test/misc/test_debug_feats.py index b032a5f9d63..2becccf4911 100644 --- a/backends/arm/test/misc/test_debug_feats.py +++ b/backends/arm/test/misc/test_debug_feats.py @@ -219,9 +219,13 @@ def test_collate_tests_tosa_INT(test_data: input_t1): ) # test that the output directory is created and contains the expected files assert os.path.exists(test_collate_dir) + found_file = False for file in os.listdir(test_collate_dir): file_name_prefix = "TOSA-1.0+INT" - assert file.endswith((f"{file_name_prefix}.json", f"{file_name_prefix}.tosa")) + found_file |= file.endswith( + (f"{file_name_prefix}.json", f"{file_name_prefix}.tosa") + ) + assert found_file os.environ.pop("TOSA_TESTCASES_BASE_PATH") shutil.rmtree("test_collate_tosa_tests", ignore_errors=True) From ca5f42c231ff349534425cb909b6c64821e44a98 Mon Sep 17 00:00:00 2001 From: Erik Lundell Date: Wed, 13 May 2026 22:17:44 +0200 Subject: [PATCH 3/3] Make sure intermediate_path exists before adding file_handler Signed-off-by: Erik Lundell Change-Id: I89a6329ae3bcc4e1316f451c71b37d934c3bf4f4 --- backends/arm/tosa/partitioner.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backends/arm/tosa/partitioner.py b/backends/arm/tosa/partitioner.py index a98aaae5318..97ce7f75248 100644 --- a/backends/arm/tosa/partitioner.py +++ b/backends/arm/tosa/partitioner.py @@ -433,8 +433,10 @@ def partition(self, exported_program: ExportedProgram) -> PartitionResult: tag_constant_data(exported_program) if self.intermediate_path is not None and logger.level <= logging.INFO: + intermediate_path = Path(self.intermediate_path) + intermediate_path.mkdir(parents=True, exist_ok=True) file_handler = logging.FileHandler( - Path(self.intermediate_path) / "partition_report.txt" + intermediate_path / "partition_report.txt" ) logger.addHandler(file_handler) logger.info(f"The following nodes were rejected for {self.tosa_spec}:")