Commit 3031090
committed
general product: handle fused-broadcast-on-the-right (rank-0 right operand)
A general product whose RIGHT operand is entirely fused with no contraction
(a fused broadcast on the right, e.g. C("b,k") = A("b,k") * B("b")) folds to a
rank-0 right operand, which the batched GEMM cannot host (TA rank-0 ranges are
null/volume-0, and gemm asserts operand.rank()==gemm_helper.rank()). The
synthetic-unit machinery covered only the rank-0 RESULT (no-external product)
and rank-0 LEFT (fused-broadcast-left) cases via a unit LEFT-external mode; the
rank-0 RIGHT case was unhandled, so folding the right operand aborted in
BatchedContractReduce::contract_pair (or silently mis-shaped with asserts off).
Add a symmetric synthetic unit RIGHT-external mode, mirroring the left one:
- ContEngine::synthetic_unit_right_external() detects outer_size(right_indices_)
== n_fused_modes_; u_right is threaded through init_struct_general (op_ ctors,
right_op NoTranspose), make_trange_general and init_distribution_general
(neB -= u_right).
- SparseShape::gemm_batched detects the right phantom by the one-rank mismatch
and guards the right-outer loops / result rank accordingly (shape-level
analog); its fold_range lambda gains an append_unit option.
- BatchedContractReduce::contract_pair detects unit_right_external, excludes it
from neB, and pads the folded right (and accumulating result) views with a
trailing unit; the member fold_range gains an append_unit option.
The synthetic mode lives only in the GemmHelper; tranges, shapes and tiles
carry the true ranks. The result gains a trailing unit mode (squeezed out of
the actual result) exactly as the left case prepends one.
Tests: general_product gains dense, ToT->ToT and block-sparse fused-broadcast-
right cases through the expression layer (which respects operand order, unlike
einsum's reordering); dot_inner gains a ->T denest fused-broadcast-right case.
This was surfaced by MPQC PNO/CSV-CCk denest products evaluated via the native
ToT*ToT->T dispatch.1 parent 5333c33 commit 3031090
5 files changed
Lines changed: 177 additions & 42 deletions
File tree
- src/TiledArray
- expressions
- tile_op
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
735 | 735 | | |
736 | 736 | | |
737 | 737 | | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
738 | 744 | | |
739 | 745 | | |
740 | | - | |
| 746 | + | |
| 747 | + | |
741 | 748 | | |
742 | 749 | | |
743 | | - | |
| 750 | + | |
| 751 | + | |
744 | 752 | | |
745 | 753 | | |
746 | 754 | | |
| |||
749 | 757 | | |
750 | 758 | | |
751 | 759 | | |
752 | | - | |
| 760 | + | |
| 761 | + | |
753 | 762 | | |
754 | | - | |
| 763 | + | |
755 | 764 | | |
756 | 765 | | |
757 | 766 | | |
| |||
772 | 781 | | |
773 | 782 | | |
774 | 783 | | |
775 | | - | |
| 784 | + | |
776 | 785 | | |
777 | | - | |
778 | | - | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
779 | 789 | | |
780 | 790 | | |
781 | 791 | | |
| |||
826 | 836 | | |
827 | 837 | | |
828 | 838 | | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
829 | 853 | | |
830 | 854 | | |
831 | 855 | | |
| |||
837 | 861 | | |
838 | 862 | | |
839 | 863 | | |
| 864 | + | |
840 | 865 | | |
841 | | - | |
| 866 | + | |
842 | 867 | | |
843 | 868 | | |
844 | 869 | | |
| |||
893 | 918 | | |
894 | 919 | | |
895 | 920 | | |
| 921 | + | |
896 | 922 | | |
897 | | - | |
| 923 | + | |
898 | 924 | | |
899 | 925 | | |
900 | 926 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1727 | 1727 | | |
1728 | 1728 | | |
1729 | 1729 | | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
1730 | 1738 | | |
1731 | 1739 | | |
1732 | 1740 | | |
1733 | 1741 | | |
1734 | 1742 | | |
1735 | 1743 | | |
1736 | | - | |
| 1744 | + | |
1737 | 1745 | | |
1738 | 1746 | | |
1739 | 1747 | | |
| |||
1751 | 1759 | | |
1752 | 1760 | | |
1753 | 1761 | | |
1754 | | - | |
1755 | | - | |
1756 | | - | |
| 1762 | + | |
| 1763 | + | |
| 1764 | + | |
| 1765 | + | |
1757 | 1766 | | |
1758 | 1767 | | |
1759 | | - | |
1760 | | - | |
1761 | | - | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
1762 | 1772 | | |
1763 | 1773 | | |
1764 | 1774 | | |
| |||
1768 | 1778 | | |
1769 | 1779 | | |
1770 | 1780 | | |
1771 | | - | |
1772 | | - | |
1773 | | - | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
1774 | 1785 | | |
1775 | 1786 | | |
1776 | 1787 | | |
| |||
1788 | 1799 | | |
1789 | 1800 | | |
1790 | 1801 | | |
1791 | | - | |
1792 | | - | |
1793 | | - | |
1794 | | - | |
1795 | | - | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
1796 | 1810 | | |
1797 | 1811 | | |
1798 | 1812 | | |
1799 | 1813 | | |
1800 | 1814 | | |
1801 | | - | |
| 1815 | + | |
| 1816 | + | |
1802 | 1817 | | |
1803 | 1818 | | |
1804 | | - | |
| 1819 | + | |
| 1820 | + | |
1805 | 1821 | | |
1806 | 1822 | | |
| 1823 | + | |
1807 | 1824 | | |
1808 | 1825 | | |
1809 | 1826 | | |
| |||
1847 | 1864 | | |
1848 | 1865 | | |
1849 | 1866 | | |
1850 | | - | |
| 1867 | + | |
| 1868 | + | |
1851 | 1869 | | |
1852 | | - | |
| 1870 | + | |
| 1871 | + | |
1853 | 1872 | | |
1854 | 1873 | | |
1855 | 1874 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
68 | 69 | | |
69 | | - | |
| 70 | + | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | | - | |
| 74 | + | |
| 75 | + | |
73 | 76 | | |
74 | 77 | | |
| 78 | + | |
75 | 79 | | |
76 | 80 | | |
77 | 81 | | |
| |||
154 | 158 | | |
155 | 159 | | |
156 | 160 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
161 | 169 | | |
162 | 170 | | |
| 171 | + | |
| 172 | + | |
163 | 173 | | |
164 | | - | |
| 174 | + | |
| 175 | + | |
165 | 176 | | |
166 | 177 | | |
167 | 178 | | |
| |||
172 | 183 | | |
173 | 184 | | |
174 | 185 | | |
175 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
176 | 189 | | |
177 | 190 | | |
178 | | - | |
| 191 | + | |
| 192 | + | |
179 | 193 | | |
180 | 194 | | |
181 | 195 | | |
| |||
206 | 220 | | |
207 | 221 | | |
208 | 222 | | |
209 | | - | |
210 | | - | |
| 223 | + | |
| 224 | + | |
211 | 225 | | |
212 | 226 | | |
213 | 227 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
97 | 122 | | |
98 | 123 | | |
99 | 124 | | |
| |||
0 commit comments