[Mlir-commits] [mlir] [mlir][linalg] Add 'compute_element_type' to linalg.elementwise op. (PR #190566)
Renato Golin
llvmlistbot at llvm.org
Mon Apr 6 10:24:16 PDT 2026
rengolin wrote:
> If specified, the input operands are converted to the type prior to computation (e.g. upcasting from f16 to f32). If the result element type differs from`compute_element_type`, the computed value is converted back to the result type.
When we discussed this last year, IIRC, the consensus was that output type IS the compute type, and we encoded as such in the operations, perhaps not explicitly enough.
When the output type is larger than the input type, linalg already represents the operation correctly (output = compute, casts before operation). When the output type is smaller than the inputs, the _"cast before operation"_ becomes a problem. The solution for the latter, back then, was to add a `cast` operation afterwards.
> If `compute_element_type` is not provided then input and output types must match.
This is a change in semantics that will break a lot of things. Even if we do introduce `compute_element`, we should not change the original semantics of casting inputs to outputs.
https://github.com/llvm/llvm-project/pull/190566
More information about the Mlir-commits
mailing list