Skip to content

Commit 7233efe

Browse files
authored
Arm backend: Dump partition report to file if intermediate dir is given (#19545)
Dump to <intermediate_dir>/partition_report.txt Signed-off-by: Erik Lundell <erik.lundell@arm.com>
1 parent 3cc1ba9 commit 7233efe

4 files changed

Lines changed: 16 additions & 1 deletion

File tree

backends/arm/ethosu/partitioner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ def __init__(
3434
self.additional_checks = additional_checks
3535
self.tosa_spec = compile_spec.tosa_spec
3636
self._custom_partition_ops: set[torch._ops.OpOverload] = set()
37+
self.intermediate_path = compile_spec._get_intermediate_path()

backends/arm/test/misc/test_debug_feats.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,13 @@ def test_collate_tests_tosa_INT(test_data: input_t1):
219219
)
220220
# test that the output directory is created and contains the expected files
221221
assert os.path.exists(test_collate_dir)
222+
found_file = False
222223
for file in os.listdir(test_collate_dir):
223224
file_name_prefix = "TOSA-1.0+INT"
224-
assert file.endswith((f"{file_name_prefix}.json", f"{file_name_prefix}.tosa"))
225+
found_file |= file.endswith(
226+
(f"{file_name_prefix}.json", f"{file_name_prefix}.tosa")
227+
)
228+
assert found_file
225229

226230
os.environ.pop("TOSA_TESTCASES_BASE_PATH")
227231
shutil.rmtree("test_collate_tosa_tests", ignore_errors=True)

backends/arm/tosa/partitioner.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import logging
1717
import operator
1818
from itertools import count
19+
from pathlib import Path
1920
from typing import Callable, cast, List, Optional, Sequence, Tuple
2021

2122
import torch
@@ -177,6 +178,7 @@ def __init__(
177178
self.tosa_spec = compile_spec.tosa_spec
178179
self.additional_checks = additional_checks
179180
self._custom_partition_ops: set[torch._ops.OpOverload] = set()
181+
self.intermediate_path = compile_spec._get_intermediate_path()
180182

181183
def register_custom_partition_op(self, op: torch._ops.OpOverload) -> None:
182184
"""Register a custom op to be considered supported by this
@@ -430,6 +432,13 @@ def partition(self, exported_program: ExportedProgram) -> PartitionResult:
430432
partition_tags = {tag: self.delegation_spec for tag in tags}
431433

432434
tag_constant_data(exported_program)
435+
if self.intermediate_path is not None and logger.level <= logging.INFO:
436+
intermediate_path = Path(self.intermediate_path)
437+
intermediate_path.mkdir(parents=True, exist_ok=True)
438+
file_handler = logging.FileHandler(
439+
intermediate_path / "partition_report.txt"
440+
)
441+
logger.addHandler(file_handler)
433442
logger.info(f"The following nodes were rejected for {self.tosa_spec}:")
434443
logger.info("\n" + reporter.get_table_report())
435444
logger.info("(Placeholders and outputs are not included in this list)")

backends/arm/vgf/partitioner.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ def __init__(
3434
self.additional_checks = additional_checks
3535
self.tosa_spec = compile_spec.tosa_spec
3636
self._custom_partition_ops: set[torch._ops.OpOverload] = set()
37+
self.intermediate_path = compile_spec._get_intermediate_path()

0 commit comments

Comments
 (0)