Repository navigation
Commit 6cbdc03
authored
Let callers gate permutability of extra elementwise ops (pytorch#22937)
Summary:
RemovePermutesAroundElementwiseOps only reasons about per-tensor
quantization. A numel-1 qparam broadcasts identically under any
permutation, so it is left wired directly to the op; that is why the
pass adds quantize_per_tensor / dequantize_per_tensor and not their
per-channel counterparts.
extra_permutable_ops bypasses that reasoning: it is unioned straight
into the permutable set with no predicate, so a caller-supplied
quantized op is treated as permutable regardless of its qparams. A
per-channel qparam has numel > 1, misses the layout-invariant branch,
and is handled as a constant input -- the pass inserts a compensating
permute on it. That both moves an axis the pass does not remap and
stops the qparam being a plain placeholder, which lowering requires.
Add an optional target_filters mapping, mirroring the one
PropagateSlice already takes, so a caller adding quantized ops can
restrict them to the cases the pass actually handles.
Authored with assistance from Claude Code.
Differential Revision: D120724474
Pull Request resolved: pytorch#229371 parent a00e2a6 commit 6cbdc03
2 files changed
Lines changed: 63 additions & 1 deletion
File tree
- backends/transforms
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| |||
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
74 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
75 | 83 | | |
76 | 84 | | |
77 | 85 | | |
| |||
99 | 107 | | |
100 | 108 | | |
101 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
102 | 117 | | |
103 | 118 | | |
104 | 119 | | |
| |||
657 | 672 | | |
658 | 673 | | |
659 | 674 | | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
660 | 678 | | |
661 | 679 | | |
662 | 680 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
922 | 922 | | |
923 | 923 | | |
924 | 924 | | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
925 | 969 | | |
926 | 970 | | |
927 | 971 | | |
| |||
0 commit comments