| 711 | |
| 712 | |
| 713 | def format_diff_result( # noqa: C901 |
| 714 | result: PTEDiffResult, verbose: bool = False |
| 715 | ) -> str: |
| 716 | lines: List[str] = [] |
| 717 | |
| 718 | lines.append( |
| 719 | f"Comparing: {result.path_a} ({_format_size(result.size_a)}) " |
| 720 | f"vs {result.path_b} ({_format_size(result.size_b)})" |
| 721 | ) |
| 722 | |
| 723 | if result.bitwise_equal: |
| 724 | lines.append("Status: bitwise equal") |
| 725 | return "\n".join(lines) |
| 726 | |
| 727 | lines.append("Status: NOT bitwise equal") |
| 728 | |
| 729 | if result.error: |
| 730 | lines.append(f"Error: {result.error}") |
| 731 | return "\n".join(lines) |
| 732 | |
| 733 | if result.version_a is not None: |
| 734 | lines.append(f"Version: {result.version_a} vs {result.version_b}") |
| 735 | |
| 736 | for pd in result.plan_diffs: |
| 737 | plan_name = pd.name_a or pd.name_b or "" |
| 738 | header = f"Plan {pd.plan_index}" |
| 739 | if plan_name: |
| 740 | header += f' "{plan_name}"' |
| 741 | if pd.name_a is not None and pd.name_b is not None: |
| 742 | header += f" (name differs: {pd.name_a!r} vs {pd.name_b!r})" |
| 743 | lines.append(f"\n{header}:") |
| 744 | |
| 745 | if pd.operators_only_in_a: |
| 746 | lines.append(f" Operators only in A: {', '.join(pd.operators_only_in_a)}") |
| 747 | if pd.operators_only_in_b: |
| 748 | lines.append(f" Operators only in B: {', '.join(pd.operators_only_in_b)}") |
| 749 | |
| 750 | if pd.delegates_only_in_a: |
| 751 | lines.append(f" Delegates only in A: {', '.join(pd.delegates_only_in_a)}") |
| 752 | if pd.delegates_only_in_b: |
| 753 | lines.append(f" Delegates only in B: {', '.join(pd.delegates_only_in_b)}") |
| 754 | |
| 755 | if pd.non_const_buffer_sizes_a is not None: |
| 756 | lines.append( |
| 757 | f" non_const_buffer_sizes: {pd.non_const_buffer_sizes_a} " |
| 758 | f"vs {pd.non_const_buffer_sizes_b}" |
| 759 | ) |
| 760 | |
| 761 | if pd.value_count_a is not None: |
| 762 | lines.append(f" Value count: {pd.value_count_a} vs {pd.value_count_b}") |
| 763 | |
| 764 | if pd.instruction_count_a is not None: |
| 765 | lines.append( |
| 766 | f" Instruction count: {pd.instruction_count_a} " |
| 767 | f"vs {pd.instruction_count_b}" |
| 768 | ) |
| 769 | |
| 770 | if pd.tensor_diffs: |