Repository navigation
Commit 33fad23
authored
Arm backend: Preserve Q/DQ in rescale pass (pytorch#22559)
### Cause
InsertRescaleInt32Pass runs after Q/DQ folding and assumes that
quantization metadata means the operator has been fully converted to an
integer path.
For partially quantized binary operators, however,
FoldAndAnnotateQParamsPass intentionally preserves the Q/DQ boundaries
so the operator continues to execute with floating-point inputs. It
still records quantization metadata for later lowering. Consequently,
the rescale pass misidentifies these operators as integer operations.
For add, this can fail because only one input has quantization
parameters; for mul, it can insert an invalid INT32 RESCALE on a
dequantized floating-point input and alter the preserved graph boundary.
### Fix
Skip INT32 rescale insertion when an operator still has a direct DQ
input or Q output. These nodes indicate that Q/DQ folding deliberately
preserved the quantization boundary, so the operator must not be
rewritten as an INT32 operation.
Fully folded quantized operators continue through the existing rescale
path unchanged.
### Testing
Added regression coverage for partially quantized add and mul. The tests
verify that the original DQ input and Q output remain connected and that
no TOSA RESCALE nodes are inserted.
cc @digantdesai @freddan80 @per @zingo @oscarandersson8218 @mansnils
@Sebastian-Larsson @robell @rascani
Signed-off-by: Sangwon Ha <sangwon.ha@arm.com>1 parent b4c53c6 commit 33fad23
2 files changed
Lines changed: 60 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
411 | 417 | | |
412 | 418 | | |
413 | 419 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| 14 | + | |
13 | 15 | | |
| 16 | + | |
14 | 17 | | |
15 | 18 | | |
16 | 19 | | |
| |||
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
| 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 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
93 | 145 | | |
94 | 146 | | |
95 | 147 | | |
| |||
0 commit comments