| Issue |
173025
|
| Summary |
[mlir][linalg] Assertion failure when tiling linalg.generic reduction that has constants in indexing maps
|
| Labels |
mlir
|
| Assignees |
|
| Reporter |
AndreyPavlenko
|
The `transform.structured.tile_reduction_using_forall` transformation crashes with an assertion failure when applied to a `generic` operation that contains constant expressions in its output indexing maps.
The error occurs in `LinalgOpPartialReductionInterface::generateInitialTensorForPartialReduction` because the code assumes all expressions in the partial result map are `AffineDimExpr`, failing to handle `AffineConstantExpr`.
Reproducer:
```MLIR
func.func @main(%arg0: tensor<1x4096x64xf32>, %arg1: tensor<1x1x64xf32>) -> tensor<1x1x64xf32> {
%0 = linalg.generic {
indexing_maps = [
affine_map<(d0, d1, d2) -> (d0, d1, d2)>,
affine_map<(d0, d1, d2) -> (d0, 0, d2)>
],
iterator_types = ["parallel", "reduction", "parallel"]
} ins(%arg0 : tensor<1x4096x64xf32>) outs(%arg1 : tensor<1x1x64xf32>) {
^bb0(%in: f32, %out: f32):
%5 = arith.addf %in, %out : f32
linalg.yield %5 : f32
} -> tensor<1x1x64xf32>
return %0 : tensor<1x1x64xf32>
}
module attributes {transform.with_named_sequence} {
transform.named_sequence @__transform_main(%arg: !transform.any_op {transform.readonly}) {
%0 = transform.structured.match ops{["linalg.generic"]} in %arg : (!transform.any_op) -> !transform.any_op
%1:4 = transform.structured.tile_reduction_using_forall %0 by tile_sizes = [0, 4, 0]
: (!transform.any_op) -> (!transform.any_op, !transform.any_op, !transform.any_op, !transform.any_op)
transform.yield
}
}
```
```bash
$ mlir-opt --transform-interpreter tile_reduction.mlir
mlir-opt: llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(From &) [To = mlir::AffineDimExpr, From = mlir::AffineExpr]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs