[Mlir-commits] [mlir] [mlir][linalg] Only skip supported casts in contraction matching (PR #198725)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Jun 12 01:38:56 PDT 2026


Chennesxu wrote:

> > Good point. Would restricting to the cast ops that linalg.generalize produces (extsi/extui/extf/trunci/truncf/sitofp/uitofp) be the right scope, or do you have a more specific set in mind?
> 
> Yes. Anything other than an exact match would not lead to a correct round trip. We may not have the appropriate semantics in named/category ops to allow for all casts to be applied (we discussed that at length last year but decided to postpone implementation).
> 
> The only safe thing to do is to apply exactly what semantics we do have today and leave others as future implementation once we have attributes that expose the kinds of casts we want for the named ops.

Thanks @rengolin — the final version implements exactly what we agreed on: the matcher now only accepts the cast ops that linalg’s `cast_signed` / `cast_unsigned` type functions produce via `convertScalarToDtype`:

`extf` / `truncf` / `extsi` / `extui` / `trunci` / `sitofp` / `uitofp` / `fptosi` / `fptoui`

Nothing else is accepted anymore. Arbitrary unary ops — including bitcasts — are no longer skipped, so generic↔named round trips stay semantics-preserving.

Could you take another look when you get a chance?

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


More information about the Mlir-commits mailing list