|
16 | 16 | import logging |
17 | 17 | import operator |
18 | 18 | from itertools import count |
| 19 | +from pathlib import Path |
19 | 20 | from typing import Callable, cast, List, Optional, Sequence, Tuple |
20 | 21 |
|
21 | 22 | import torch |
@@ -177,6 +178,7 @@ def __init__( |
177 | 178 | self.tosa_spec = compile_spec.tosa_spec |
178 | 179 | self.additional_checks = additional_checks |
179 | 180 | self._custom_partition_ops: set[torch._ops.OpOverload] = set() |
| 181 | + self.intermediate_path = compile_spec._get_intermediate_path() |
180 | 182 |
|
181 | 183 | def register_custom_partition_op(self, op: torch._ops.OpOverload) -> None: |
182 | 184 | """Register a custom op to be considered supported by this |
@@ -430,6 +432,13 @@ def partition(self, exported_program: ExportedProgram) -> PartitionResult: |
430 | 432 | partition_tags = {tag: self.delegation_spec for tag in tags} |
431 | 433 |
|
432 | 434 | 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) |
433 | 442 | logger.info(f"The following nodes were rejected for {self.tosa_spec}:") |
434 | 443 | logger.info("\n" + reporter.get_table_report()) |
435 | 444 | logger.info("(Placeholders and outputs are not included in this list)") |
|
0 commit comments