[Mlir-commits] [mlir] [mlir][tensor] Make tensor::PadOp a ReifyRankedShapedTypeOpInterface and add a PadOp::FoldReifiedShape canonicalization (PR #145732)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Jun 26 12:42:16 PDT 2025


MaheshRavishankar wrote:

> @MaheshRavishankar @matthias-springer I think we may need a longer alignment session here but TL;DR my position atm is:
> 

I think we have had multiple of these sessions.  Happy to chat offline to give context, but Tl;DR is MLIR canonicalizations have become too much of a kitchen sink and we should avoid. What we need are fixed point iterations that do a specific transformation of the program. For example, the `tensor.cast` resolution is a well defined fixed point (unfortunately this is today bundled into canonicalizer and should be removed IMO). `tensor.dim` resolution is a well defined fixed point which is done with [`populateResolveRankedShapedTypeResultDimsPatterns`](https://github.com/llvm/llvm-project/blob/a0c5f1992d2188dd58987445aa00a55edad2357f/mlir/include/mlir/Dialect/MemRef/Transforms/Transforms.h#L52`) . We should be exposing fixed points (and potentially allow combination of fixed points for things that work together). Bundling that in a canonicalization that allows no control of what is run is a huge flaw that in my view we should work ourselves out of.

In this particular case though I think what you are trying to do during dim resolution is cast folding. Can you say why `https://github.com/llvm/llvm-project/pull/145732/files#diff-025c342b2a76f2edaae5557ff3e81b0b9ef9f47107359e78d85654581318d154R3864` these patterns dont already do this. Instead of fixing that, this seems to be adding another pattern. I am more curious as to what the existing cast folding misses that you needed to add it during dim resolution.

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


More information about the Mlir-commits mailing list