Commit 1c26f1f
committed
_aten_to_core, _utils: harden mixed-source SymInt lowerings under dynamic shapes
Six related fixes that surface together when exporting models whose FX
graphs combine SymInt-derived shape arithmetic with mixed source
element types and ranks:
1. _aten_to_core_resolver / replace_binary_ops _op_map: register a
bare 'pow' entry alongside the variant-suffixed ones. Some
torch.export rewrites leave ``aten.pow`` as the OpOverloadPacket
target with no overload suffix; without this entry the converter
raises ``Unsupported ATen op: pow``.
2. Same registries for bare 'round': torch.export can leave
``aten.round`` without a ``.default`` overload, mirroring the pow
case.
3. upsample_build_output_shape_dynamic: ensure each (out_h, out_w)
operand is rank-1 with int32 element type before the concat that
builds the output shape — the dialect verifier rejects mixed-rank
/ mixed-element-type concat inputs. Hits when out_h/out_w are
SymInts derived from ``round(SymFloat)`` arithmetic.
4. get_operand mixed-list path (SymInt + plain int): normalise each
resolved Value to the same canonical rank-1 si32 form and emit
plain-int constants with explicit ``dtype=np.int32`` so the
dim-vector concat sees uniform operands. Hits ops like ``view``,
``expand``, ``reshape``, ``repeat`` whenever a dim list mixes
SymInts with ints.
5. replace_cat: when one input has a dynamic non-concat axis and a
sibling has a known static size for that axis, reshape the
dynamic side to that static size before the concat. Localised
shape inference using the fact that all non-concat dims must be
equal — multiple distinct static sizes is left for the dialect
verifier to reject.
6. replace_arange_start_step: unify start/end/step element types to
the FX node's output dtype before ``coreai.range_``. Mirrors
aten.arange's internal type promotion since coreai.range_'s
verifier requires uniform element types.
Adds a shared ``to_rank1_int32(v)`` helper in ``_utils.py`` so fixes
3 and 4 share one canonical normalization (rank-0 → rank-1, cast to
signed int32 if needed); both call sites collapse to one line per
operand.
One regression test per non-trivial fix, each verified to FAIL
without the fix and PASS with it (verified by reverting each fix
individually):
- TestRound: bare ``aten.round`` overload-packet target must lower.
- TestUpsampleNearest2d / TestUpsampleBilinear2d::test_round_symfloat_size:
``round((num / aspect) ** 0.5) * 14`` output_size produces SymInts
whose Value type doesn't match the int32 constants used elsewhere.
Pre-fix: ``coreai.concat`` raises ``Operation creation failed``.
- TestView::test_view_with_round_symfloat_dims: same trigger applied
to a ``view([1, C, h, w])`` mixed list. Pre-fix: ``expected the
same element type for all inputs to concat``.
- TestCat::test_dynamic_vs_static_non_concat_axis: ``Dim.AUTO`` on
one side + static sibling forces non-concat-axis promotion.
- TestArange::test_symint_end_with_float_start_step: float ``arange``
with SymInt-derived end exercises the element-type unify.1 parent 7171b3b commit 1c26f1f
4 files changed
Lines changed: 391 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
644 | 644 | | |
645 | 645 | | |
646 | 646 | | |
647 | | - | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
648 | 653 | | |
649 | 654 | | |
650 | | - | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
651 | 658 | | |
652 | 659 | | |
653 | | - | |
654 | | - | |
655 | | - | |
656 | | - | |
657 | | - | |
| 660 | + | |
658 | 661 | | |
659 | 662 | | |
660 | 663 | | |
| |||
814 | 817 | | |
815 | 818 | | |
816 | 819 | | |
| 820 | + | |
817 | 821 | | |
818 | 822 | | |
819 | 823 | | |
| |||
944 | 948 | | |
945 | 949 | | |
946 | 950 | | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
947 | 981 | | |
948 | 982 | | |
949 | 983 | | |
| |||
2595 | 2629 | | |
2596 | 2630 | | |
2597 | 2631 | | |
| 2632 | + | |
2598 | 2633 | | |
2599 | 2634 | | |
2600 | 2635 | | |
| |||
3434 | 3469 | | |
3435 | 3470 | | |
3436 | 3471 | | |
| 3472 | + | |
3437 | 3473 | | |
3438 | 3474 | | |
3439 | 3475 | | |
3440 | 3476 | | |
3441 | 3477 | | |
3442 | 3478 | | |
3443 | 3479 | | |
| 3480 | + | |
3444 | 3481 | | |
3445 | 3482 | | |
3446 | 3483 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
178 | 195 | | |
179 | 196 | | |
180 | 197 | | |
| |||
192 | 209 | | |
193 | 210 | | |
194 | 211 | | |
195 | | - | |
196 | | - | |
| 212 | + | |
| 213 | + | |
197 | 214 | | |
198 | 215 | | |
199 | 216 | | |
| |||
986 | 1003 | | |
987 | 1004 | | |
988 | 1005 | | |
989 | | - | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
990 | 1009 | | |
991 | | - | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
992 | 1013 | | |
993 | 1014 | | |
994 | 1015 | | |
| |||
0 commit comments