Commit 9602d4f
committed
einsum: delegate nesting-preserving products to the expression layer
Two general-product shapes that einsum handled with bespoke machinery are
nesting-preserving (the result keeps the operand nesting), so the general-
product expression engine can own them; only the type-mutating ToT*ToT->T
denest reduction remains einsum's by default.
* Fused broadcast C(h,e) = A(h) * B(h,e) (one operand entirely fused, no
contraction): replaces the replicate_array() expand-then-Hadamard with a
direct delegation. The engine evaluates it natively once the fully-fused
operand leads -- its folded left tile is rank-0, restored by a synthetic
unit left-external mode. ContEngine::synthetic_unit_left_external() now
fires for a rank-0 LEFT operand (broadcast), not only a rank-0 RESULT
(no-external). einsum orders the fully-fused operand first and applies any
inner result permutation afterward.
* No-external products C(h;..) = A(h,i;..) * B(h,i;..) (fused + contracted,
no free index) now default to the expression layer (the existing
no-external synthetic-unit mode). The legacy local kernel is retained only
behind einsum_legacy_subworld() as the cross-check oracle, mirroring the
generalized-subworld path.
Tests: dense fused broadcast (both operand orders), ToT no-external with
inner Hadamard and inner contraction.1 parent 355f9c8 commit 9602d4f
3 files changed
Lines changed: 157 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
673 | 673 | | |
674 | 674 | | |
675 | 675 | | |
676 | | - | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
677 | 683 | | |
678 | 684 | | |
679 | | - | |
680 | | - | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
681 | 704 | | |
| 705 | + | |
682 | 706 | | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
| 707 | + | |
693 | 708 | | |
694 | 709 | | |
695 | 710 | | |
| |||
791 | 806 | | |
792 | 807 | | |
793 | 808 | | |
794 | | - | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
795 | 831 | | |
796 | 832 | | |
797 | 833 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
677 | 677 | | |
678 | 678 | | |
679 | 679 | | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
690 | 692 | | |
691 | | - | |
| 693 | + | |
692 | 694 | | |
693 | 695 | | |
694 | 696 | | |
| |||
749 | 751 | | |
750 | 752 | | |
751 | 753 | | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
752 | 771 | | |
753 | 772 | | |
754 | 773 | | |
755 | 774 | | |
756 | 775 | | |
757 | 776 | | |
758 | 777 | | |
759 | | - | |
760 | | - | |
761 | | - | |
762 | | - | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
763 | 782 | | |
764 | 783 | | |
765 | 784 | | |
| |||
812 | 831 | | |
813 | 832 | | |
814 | 833 | | |
815 | | - | |
816 | | - | |
817 | | - | |
818 | | - | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
819 | 838 | | |
820 | 839 | | |
821 | 840 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
237 | 237 | | |
238 | 238 | | |
239 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
240 | 271 | | |
241 | 272 | | |
242 | 273 | | |
| |||
778 | 809 | | |
779 | 810 | | |
780 | 811 | | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
781 | 848 | | |
782 | 849 | | |
783 | 850 | | |
| |||
1241 | 1308 | | |
1242 | 1309 | | |
1243 | 1310 | | |
1244 | | - | |
1245 | | - | |
1246 | | - | |
1247 | | - | |
1248 | | - | |
1249 | | - | |
1250 | | - | |
| 1311 | + | |
| 1312 | + | |
1251 | 1313 | | |
1252 | 1314 | | |
1253 | 1315 | | |
| |||
1278 | 1340 | | |
1279 | 1341 | | |
1280 | 1342 | | |
1281 | | - | |
1282 | 1343 | | |
1283 | 1344 | | |
1284 | 1345 | | |
| |||
0 commit comments