[Mlir-commits] [mlir] [mlir][linalg] Add `comp-type` to new elementwise-op. (PR #131542)

Javed Absar llvmlistbot at llvm.org
Mon Mar 17 05:02:12 PDT 2025


javedabsar1 wrote:

> I'm confused. This does not add a `comp-type` to element-wise, just a `cast` operation to the `output-type`. The PR description seems wrong.
> 
> Also, as @MaheshRavishankar noted earlier, there are cases where you have different casts for different inputs. I think for now we can assume the output type isn't casted.

Apologies I should have explained @rengolin and @banach-space . I should have explained this diff better. My lame excuses - it was sunday night and i was hungry and ....

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 (a), lets take example. 
legacy IR (note f16 input): 
` %0 = linalg.elemwise_unary ins(%lhs: tensor<4x8xi16>) outs(%output: tensor<4x8xf32>) -> tensor<4x8xf32>`
after linalg-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>
    return %0 : tensor<4x8xf32>
  }
```








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


More information about the Mlir-commits mailing list