[Mlir-commits] [mlir] [mlir][linalg] Flag to guard MoveInitOperandsToInput in LinalgFoldUnitExtendDimsPass (PR #157941)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Sep 19 12:13:13 PDT 2025
sdalvi-quic wrote:
Thank you for raising the concern.
For the input IR, we're initializing the outs(output) outside the linalg.generic op before using it, to ensure value correctness is maintained.
I hope this aligns with what you were referring to in your comment.
> Ok, Actually this is also related to another PR I was reviewing. First of all this input is wrong
>
> ```
> %0 = linalg.generic {
> indexing_maps = [<(affine_map<(d0) -> (d0), affine_map<(d0) -> (d0)>],
> iterator_types = ["parallel"]}
> ins(%input : tensor<?xf32>) outs(%output : tensor<?xf32>) {
> ^bb0(%b0 : f32, %b1: f32):
> %1 = arith.maximumf %b0, %b1: f32
> linalg.yield %1 : f32
> } -> tensor<?xf32>
> ```
>
> You are reading the `outs` value for a `parallel` operation. In my book that is undefined behavior. If anything the pattern you are masking off is actually trying to be too smart and making it the correct representation
>
> ```
> %empty = tensor.empty(...) : tensor<?xf32>
> %0 = linalg.generic {
> indexing_maps = [<(affine_map<(d0) -> (d0), affine_map<(d0) -> (d0)>],
> iterator_types = ["parallel"]}
> ins(%input, %output : tensor<?xf32>, tensor<?xf32>) outs(%empty: tensor<?xf32>) {
> ^bb0(%b0 : f32, %b1: f32, %b2 : ):
> %1 = arith.maximumf %b0, %b1 : f32
> linalg.yield %1 : f32
> } -> tensor<?xf32>
> ```
>
> So before we go ahead with this change... id strongly suggest looking at your input... Input seems off to me.
https://github.com/llvm/llvm-project/pull/157941
More information about the Mlir-commits
mailing list