[Mlir-commits] [mlir] [mlir][linalg] Type conversion of operands in new elementwise-op. (PR #131542)

Andrzej Warzyński llvmlistbot at llvm.org
Fri Mar 21 04:50:32 PDT 2025


banach-space wrote:

> Apologies @rengolin and @banach-space . I should have explained better .

No apology required, this is obviously super clear in your head. You wouldn't know what's not clear in ours if we didn't ask :)

> My intention was/still-is -
(a) align with legacy `linalg.elemwise_unary /binary .
(b) allow type-conversion of inputs of the new linalg.elementwise to the type of the result-type.

OK, just to clarify. From the examples that you shared, `linalg.elementwise` already does casting similar to what the legacy Ops do, right? So there's nothing to align? I am going by this example:

```
Now, the same thing in new elementwise

 %0 = linalg.elementwise 
             kind=#linalg.elementwise_kind<exp>
             ins(%arg0 : tensor<4x8xi16>) outs(%arg1 : tensor<4x8xf32>) -> tensor<4x8xf32>
after generalize -

    %0 = linalg.generic
              {indexing_maps = [#map, #map], iterator_types = ["parallel", "parallel"]}
              ins(%arg0 : tensor<4x8xi16>) outs(%arg1 : tensor<4x8xf32>) {
    ^bb0(%in: i16, %out: f32):
      %1 = arith.sitofp %in : i16 to f32
      %2 = math.exp %1 : f32
      linalg.yield %2 : f32
    } -> tensor<4x8xf32>
```

All in all, makes sense to me. I've left a few minor comments. My bigger comment is to update the summary to communicate the actual extension when compare to:
* the legacy Op
* what's currently supported by the new Op.

Once that's done, I am happy to approve. Many thanks for working on this 🙏🏻 

https://github.com/llvm/llvm-project/pull/131542


More information about the Mlir-commits mailing list