Commit b754194
Add decomposition for aten.miopen_batch_norm to aten.native_batch_norm
On ROCm 7.1+ with MIOpen 3.5+, PyTorch decomposes BatchNorm2d with
channels-last layout to aten.miopen_batch_norm instead of
aten._native_batch_norm_legit_functional. torch-mlir didn't support
this op, causing legalization to fail.
Fixes: #4476
- Register aten.miopen_batch_norm in torch_ods_gen.py (signature:
(Tensor, Tensor, Tensor?, Tensor?, Tensor?, bool, float, float) -> (Tensor, Tensor, Tensor))
- Add decomposition pattern to DecomposeComplexOps.cpp that rewrites
miopen_batch_norm to native_batch_norm by passing weight directly
(type-compatible since native_batch_norm accepts AnyTorchOptionalTensorType)
- Add lit test verifying the op is decomposed away
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 17ae730 commit b754194
File tree
4 files changed
+70
-0
lines changed- include/torch-mlir/Dialect/Torch/IR
- lib/Dialect/Torch/Transforms
- projects/pt1/python/torch_mlir/jit_ir_importer/build_tools
- test/Dialect/Torch
4 files changed
+70
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7353 | 7353 | | |
7354 | 7354 | | |
7355 | 7355 | | |
| 7356 | + | |
| 7357 | + | |
| 7358 | + | |
| 7359 | + | |
| 7360 | + | |
| 7361 | + | |
| 7362 | + | |
| 7363 | + | |
| 7364 | + | |
| 7365 | + | |
| 7366 | + | |
| 7367 | + | |
| 7368 | + | |
| 7369 | + | |
| 7370 | + | |
| 7371 | + | |
| 7372 | + | |
| 7373 | + | |
| 7374 | + | |
| 7375 | + | |
| 7376 | + | |
| 7377 | + | |
| 7378 | + | |
| 7379 | + | |
| 7380 | + | |
| 7381 | + | |
| 7382 | + | |
| 7383 | + | |
| 7384 | + | |
| 7385 | + | |
| 7386 | + | |
| 7387 | + | |
7356 | 7388 | | |
7357 | 7389 | | |
7358 | 7390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8526 | 8526 | | |
8527 | 8527 | | |
8528 | 8528 | | |
| 8529 | + | |
| 8530 | + | |
| 8531 | + | |
| 8532 | + | |
| 8533 | + | |
| 8534 | + | |
| 8535 | + | |
| 8536 | + | |
| 8537 | + | |
| 8538 | + | |
| 8539 | + | |
| 8540 | + | |
| 8541 | + | |
| 8542 | + | |
| 8543 | + | |
| 8544 | + | |
| 8545 | + | |
| 8546 | + | |
| 8547 | + | |
| 8548 | + | |
| 8549 | + | |
| 8550 | + | |
8529 | 8551 | | |
8530 | 8552 | | |
8531 | 8553 | | |
| |||
13380 | 13402 | | |
13381 | 13403 | | |
13382 | 13404 | | |
| 13405 | + | |
13383 | 13406 | | |
13384 | 13407 | | |
13385 | 13408 | | |
| |||
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
631 | 631 | | |
632 | 632 | | |
633 | 633 | | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
634 | 637 | | |
635 | 638 | | |
636 | 639 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1013 | 1013 | | |
1014 | 1014 | | |
1015 | 1015 | | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
0 commit comments