Commit 35010fc
authored
[Torch][FX] Rewrite as_strided before Torch IR import (#4585)
Move `aten.as_strided.default` handling out of backend/Torch IR
decomposition and into FX import. The new
`torch_mlir.extras.fx_as_strided` pass runs before Torch IR
construction, while FakeTensor metadata still carries storage offset,
physical strides, and layout information. Supported static `as_strided`
reads are rewritten to `aten.index.Tensor`, raw
`aten.as_strided.default` is rejected if it reaches generic ATen import.
Delete the existing Torch `DecomposeComplexOps` lowering and the direct
TorchToTOSA lowering for `aten.as_strided`. Those lowerings flattened
the immediate tensor value and could not recover storage/layout metadata
after import, which is unsafe for channels-last tensors and some
view/copy boundaries.
Add FX importer tests and e2e coverage for normal view chains, stepped
slices, `view -> contiguous -> as_strided`, channels-last inputs and
parameters, and `to(memory_format=channels_last) -> as_strided`. Update
xfail/crashing sets for ONNX cases where export has already lost storage
semantics or aborts before the runner can report an xfail.
Also retag StableHLO integer resource literals to signless result types.
The FX rewrite emits literal index tensors, and StableHLO constants must
use signless integer element types even when the resource blob came from
a signed Torch integer tensor.1 parent dd41cf6 commit 35010fc
11 files changed
Lines changed: 1125 additions & 363 deletions
File tree
- lib
- Conversion
- TorchToStablehlo
- TorchToTosa
- Dialect/Torch/Transforms
- projects/pt1
- e2e_testing
- python/torch_mlir_e2e_test/test_suite
- python
- torch_mlir/extras
- test
- Conversion/TorchToTosa
- python/fx_importer
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
894 | 895 | | |
895 | 896 | | |
896 | 897 | | |
897 | | - | |
898 | | - | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
899 | 908 | | |
900 | 909 | | |
901 | 910 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9082 | 9082 | | |
9083 | 9083 | | |
9084 | 9084 | | |
9085 | | - | |
9086 | | - | |
9087 | | - | |
9088 | | - | |
9089 | | - | |
9090 | | - | |
9091 | | - | |
9092 | | - | |
9093 | | - | |
9094 | | - | |
9095 | | - | |
9096 | | - | |
9097 | | - | |
9098 | | - | |
9099 | | - | |
9100 | | - | |
9101 | | - | |
9102 | | - | |
9103 | | - | |
9104 | | - | |
9105 | | - | |
9106 | | - | |
9107 | | - | |
9108 | | - | |
9109 | | - | |
9110 | | - | |
9111 | | - | |
9112 | | - | |
9113 | | - | |
9114 | | - | |
9115 | | - | |
9116 | | - | |
9117 | | - | |
9118 | | - | |
9119 | | - | |
9120 | | - | |
9121 | | - | |
9122 | | - | |
9123 | | - | |
9124 | | - | |
9125 | | - | |
9126 | | - | |
9127 | | - | |
9128 | | - | |
9129 | | - | |
9130 | | - | |
9131 | | - | |
9132 | | - | |
9133 | | - | |
9134 | | - | |
9135 | | - | |
9136 | | - | |
9137 | | - | |
9138 | | - | |
9139 | | - | |
9140 | | - | |
9141 | | - | |
9142 | | - | |
9143 | | - | |
9144 | | - | |
9145 | | - | |
9146 | | - | |
9147 | | - | |
9148 | | - | |
9149 | | - | |
9150 | | - | |
9151 | | - | |
9152 | | - | |
9153 | | - | |
9154 | | - | |
9155 | | - | |
9156 | | - | |
9157 | | - | |
9158 | | - | |
9159 | | - | |
9160 | | - | |
9161 | | - | |
9162 | | - | |
9163 | | - | |
9164 | | - | |
9165 | | - | |
9166 | | - | |
9167 | | - | |
9168 | | - | |
9169 | | - | |
9170 | | - | |
9171 | | - | |
9172 | | - | |
9173 | | - | |
9174 | | - | |
9175 | | - | |
9176 | | - | |
9177 | | - | |
9178 | | - | |
9179 | | - | |
9180 | | - | |
9181 | | - | |
9182 | | - | |
9183 | | - | |
9184 | | - | |
9185 | | - | |
9186 | | - | |
9187 | 9085 | | |
9188 | 9086 | | |
9189 | 9087 | | |
| |||
11472 | 11370 | | |
11473 | 11371 | | |
11474 | 11372 | | |
11475 | | - | |
11476 | 11373 | | |
11477 | 11374 | | |
11478 | 11375 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13176 | 13176 | | |
13177 | 13177 | | |
13178 | 13178 | | |
13179 | | - | |
13180 | | - | |
13181 | | - | |
13182 | | - | |
13183 | | - | |
13184 | | - | |
13185 | | - | |
13186 | | - | |
13187 | | - | |
13188 | | - | |
13189 | | - | |
13190 | | - | |
13191 | | - | |
13192 | | - | |
13193 | | - | |
13194 | | - | |
13195 | | - | |
13196 | | - | |
13197 | | - | |
13198 | | - | |
13199 | | - | |
13200 | | - | |
13201 | | - | |
13202 | | - | |
13203 | | - | |
13204 | | - | |
13205 | | - | |
13206 | | - | |
13207 | | - | |
13208 | | - | |
13209 | | - | |
13210 | | - | |
13211 | | - | |
13212 | | - | |
13213 | | - | |
13214 | | - | |
13215 | | - | |
13216 | | - | |
13217 | | - | |
13218 | | - | |
13219 | | - | |
13220 | | - | |
13221 | | - | |
13222 | | - | |
13223 | | - | |
13224 | | - | |
13225 | | - | |
13226 | | - | |
13227 | | - | |
13228 | | - | |
13229 | | - | |
13230 | | - | |
13231 | | - | |
13232 | | - | |
13233 | | - | |
13234 | | - | |
13235 | | - | |
13236 | | - | |
13237 | | - | |
13238 | | - | |
13239 | | - | |
13240 | | - | |
13241 | | - | |
13242 | | - | |
13243 | | - | |
13244 | | - | |
13245 | | - | |
13246 | | - | |
13247 | | - | |
13248 | | - | |
13249 | | - | |
13250 | | - | |
13251 | | - | |
13252 | | - | |
13253 | | - | |
13254 | | - | |
13255 | | - | |
13256 | | - | |
13257 | | - | |
13258 | | - | |
13259 | | - | |
13260 | | - | |
13261 | | - | |
13262 | | - | |
13263 | | - | |
13264 | | - | |
13265 | | - | |
13266 | | - | |
13267 | | - | |
13268 | | - | |
13269 | | - | |
13270 | | - | |
13271 | | - | |
13272 | | - | |
13273 | | - | |
13274 | | - | |
13275 | | - | |
13276 | | - | |
13277 | | - | |
13278 | | - | |
13279 | | - | |
13280 | | - | |
13281 | | - | |
13282 | | - | |
13283 | | - | |
13284 | | - | |
13285 | | - | |
13286 | | - | |
13287 | | - | |
13288 | | - | |
13289 | | - | |
13290 | | - | |
13291 | | - | |
13292 | | - | |
13293 | | - | |
13294 | | - | |
13295 | | - | |
13296 | | - | |
13297 | | - | |
13298 | | - | |
13299 | | - | |
13300 | | - | |
13301 | | - | |
13302 | | - | |
13303 | | - | |
13304 | | - | |
13305 | | - | |
13306 | | - | |
13307 | | - | |
13308 | | - | |
13309 | | - | |
13310 | | - | |
13311 | | - | |
13312 | | - | |
13313 | | - | |
13314 | | - | |
13315 | | - | |
13316 | | - | |
13317 | | - | |
13318 | | - | |
13319 | | - | |
13320 | | - | |
13321 | | - | |
13322 | | - | |
13323 | | - | |
13324 | | - | |
13325 | | - | |
13326 | | - | |
13327 | | - | |
13328 | | - | |
13329 | | - | |
13330 | | - | |
13331 | | - | |
13332 | | - | |
13333 | | - | |
13334 | | - | |
13335 | | - | |
13336 | | - | |
13337 | | - | |
13338 | | - | |
13339 | | - | |
13340 | | - | |
13341 | | - | |
13342 | | - | |
13343 | | - | |
13344 | | - | |
13345 | | - | |
13346 | | - | |
13347 | | - | |
13348 | | - | |
13349 | | - | |
13350 | | - | |
13351 | | - | |
13352 | | - | |
13353 | | - | |
13354 | | - | |
13355 | | - | |
13356 | | - | |
13357 | | - | |
13358 | | - | |
13359 | | - | |
13360 | | - | |
13361 | | - | |
13362 | | - | |
13363 | | - | |
13364 | | - | |
13365 | | - | |
13366 | | - | |
13367 | | - | |
13368 | | - | |
13369 | | - | |
13370 | | - | |
13371 | | - | |
13372 | | - | |
13373 | | - | |
13374 | | - | |
13375 | | - | |
13376 | | - | |
13377 | | - | |
13378 | 13179 | | |
13379 | 13180 | | |
13380 | 13181 | | |
| |||
13709 | 13510 | | |
13710 | 13511 | | |
13711 | 13512 | | |
13712 | | - | |
13713 | 13513 | | |
13714 | 13514 | | |
13715 | 13515 | | |
| |||
0 commit comments