Skip to content

Commit 1fb8c73

Browse files
Arm backend: Print delegation summary (pytorch#20105)
Print delegation summary when running aot_arm_compiler. This is complementary to the outputed delegation_info.txt and aims to make delegation info even clearer to end user cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @robell @rascani Signed-off-by: Christoffer J.L <christoffer.johanssonlundqvist@arm.com>
1 parent 8fad999 commit 1fb8c73

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

backends/arm/scripts/aot_arm_compiler.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,51 @@ def dump_delegation_info(edge, intermediate_files_folder: Optional[str] = None):
531531
)
532532
with open(delegation_file_path, "w") as file:
533533
file.write(delegation_info_string)
534+
print_delegation_summary(delegation_info, intermediate_files_folder)
535+
536+
537+
def print_delegation_summary(
538+
delegation_info,
539+
intermediate_files_folder: Optional[str] = None,
540+
) -> None:
541+
non_delegated_ops = sorted(
542+
(
543+
(breakdown.op_type, breakdown.non_delegated)
544+
for breakdown in delegation_info.delegation_by_operator.values()
545+
if breakdown.non_delegated > 0
546+
),
547+
key=lambda item: (-item[1], item[0]),
548+
)
549+
550+
summary_lines = ["Delegation summary:"]
551+
if delegation_info.num_delegated_nodes == 0:
552+
summary_lines.append(" Model was not delegated.")
553+
elif delegation_info.num_non_delegated_nodes == 0:
554+
summary_lines.append(" Model was fully delegated.")
555+
else:
556+
summary_lines.append(" Model was partially delegated.")
557+
558+
summary_lines.append(
559+
f" Delegated partitions for silicon acceleration: {delegation_info.num_delegated_subgraphs}"
560+
)
561+
summary_lines.append(
562+
f" Non-delegated ops: {delegation_info.num_non_delegated_nodes}"
563+
)
564+
565+
if non_delegated_ops:
566+
summary_lines.append(" Non-delegated operators:")
567+
for op_type, count in non_delegated_ops:
568+
summary_lines.append(f" - {op_type}: {count}")
569+
570+
if intermediate_files_folder is not None:
571+
delegation_file_path = os.path.join(
572+
intermediate_files_folder, "delegation_info.txt"
573+
)
574+
summary_lines.append("")
575+
summary_lines.append("Full delegation report:")
576+
summary_lines.append(f" {delegation_file_path}")
577+
578+
print("\n".join(summary_lines))
534579

535580

536581
def _get_args():

0 commit comments

Comments
 (0)