[Mlir-commits] [mlir] feat(linalg): add a way to pass controlFn to `foldIntoPackUnpackPatterns` (PR #143685)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Jun 23 13:49:24 PDT 2025


MaheshRavishankar wrote:

> > I think this is an indication that you dont want to be using pattern application. In such situations we have found it better to expose the core transformation done by the pattern as a function and then just call that function using a pass downstream. You can the have whatever control you want in that pass.
> 
> Sure, I can do that. One thing I had in mind while doing this was the compatibility with current downstream users of the pattern. I guess with that change, users would also have to adjust to it.

You can keep the patterns unchanged without a control function. You can add the transformation methods with the control function. The patterns can "apply always", but downstream you can change your pass to walk the function and apply the transformation as needed.

> 
> Also, just to clarify this, in that case, I would expose _every_ pattern inside `populateFoldIntoPackUnpackPatterns` as functions, right?

Yeah. If you need to control all of them, then yes.


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


More information about the Mlir-commits mailing list