| Issue |
241070
|
| Summary |
[mlir][linalg] Verifier crashes on rank-0 linalg.transpose with empty permutation
|
| Labels |
mlir
|
| Assignees |
|
| Reporter |
lin334141-cell
|
## Summary
`mlir-opt` crashes when verifying a rank-0 `linalg.transpose` with `permutation = []`, without running any transformation pass.
`TransposeOp::verify()` accepts the empty permutation for a rank-0 input, but subsequent interface verification calls `TransposeOp::getIndexingMaps()`, which passes the empty vector to `AffineMap::getPermutationMap()` and triggers an assertion.
## Minimal Reproducer
```mlir
module {
func.func @t(%a: memref<i64>, %b: memref<i64>) {
linalg.transpose ins(%b : memref<i64>)
outs(%a : memref<i64>)
permutation = []
return
}
}
```
Run:
```bash
mlir-opt min.mlir --verify-each
```
**Actual behavior:** `mlir-opt` aborts with:
```text
Assertion failed: (!permutation.empty() &&
"Cannot create permutation map from empty permutation vector"),
function getPermutationMap, file AffineMap.cpp.
```
**Expected behavior:** The verifier should either accept a valid rank-0 transpose or reject it with a diagnostic, rather than crashing.
## Root Cause
`linalg::TransposeOp::getIndexingMaps()` in `mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp` calls `AffineMap::getPermutationMap()` without handling an empty permutation.
Although `TransposeOp::verify()` accepts `permutation = []` for rank-0 operands, `AffineMap::getPermutationMap()` requires a non-empty vector and asserts.
The crash also reproduces with rank-0 tensors. A rank-1 transpose with `permutation = [0]` passes verification.
## Related Issues
This is distinct from #231817 (fixed by #231940), which involves `vector.transpose` and `vector.extract` during folding.
The present crash occurs in **`linalg.transpose` interface verification**, not Vector folding.
## Tested Versions
Reproduced on:
- LLVM `67005b724c` (24.0.0git)
- LLVM `c1856996d6` (24.0.0git)
- LLVM `61817b48e` (main)
All three assertion-enabled builds reproduce the same crash.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs