[Mlir-commits] [mlir] [mlir][linalg] Add broadcast splat to fill canonicalization (PR #195980)
Hocky Yudhiono
llvmlistbot at llvm.org
Wed May 6 18:44:02 PDT 2026
hockyy wrote:
> Here too, the fill seems superfluous.
Hi, for this one, if we change it to splat, it cannot handle dynamic cases. Should we bail-out in this case? wdyt?
```
module {
func.func @broadcast_splat_constant_dynamic_shape(%arg0: tensor<?x3xf32>) -> tensor<?x3xf32> {
%cst = arith.constant dense<1.000000e+00> : tensor<3xf32>
%broadcasted = linalg.broadcast ins(%cst : tensor<3xf32>) outs(%arg0 : tensor<?x3xf32>) dimensions = [0]
return %broadcasted : tensor<?x3xf32>
}
}
hocky at hocky:~/llvm/llvm-project/build_clion$ mlir-opt why.mlir --canonicalize
module {
func.func @broadcast_splat_constant_dynamic_shape(%arg0: tensor<?x3xf32>) -> tensor<?x3xf32> {
%cst = arith.constant 1.000000e+00 : f32
%0 = linalg.fill ins(%cst : f32) outs(%arg0 : tensor<?x3xf32>) -> tensor<?x3xf32>
return %0 : tensor<?x3xf32>
}
}
```
https://github.com/llvm/llvm-project/pull/195980
More information about the Mlir-commits
mailing list