[mlir] Special handling for pattern rewrite on maskable op
Pattern rewrite on maskable ops requires special handing when they are in vector.mask region as the vector.mask region only allows a single maskable op (https://discourse.llvm.org/t/rfc-vector-masking-representation-in-mlir/64964)
In https://github.com/llvm/llvm-project/pull/76468 we add some special checks in related pattern rewrites to skip those cases. But as the comment https://github.com/llvm/llvm-project/pull/76468#issuecomment-1897699116, we can provide a specialized pattern rewrite base class to help writing patterns for maskable op. For example, transform vector.mask and its inner maskable op together
I was going through #76468 and I believe I can implement a pattern rewrite for maskops. Could I be assigned this issue?
@tanmaysachan: Just prepare pull request and mention it on this page.
Hey 👋🏻
I'm trying to unblock myself and I have uploaded a partial fix here: https://github.com/llvm/llvm-project/pull/81906. It only covers one particular pattern, castAwayContractionLeadingOneDim. There's 2 more - I won't be looking into those in the coming 2 weeks. @tanmaysachan I am more than happy to fix those as well, but also don't mind waiting if you plan to send a fix. Thanks!
@banach-space Hi! Sorry for the delay, I do plan on submitting a PR this week. It should cover these cases!
@banach-space Hi! Sorry for the delay, I do plan on submitting a PR this week. It should cover these cases!
Would you mind taking a look at my PR? If you're taking similar approach, then we may as well land that and at least I'm unblocked. If you're proposing something different, I can close that and just wait a bit. I am happy either way.
@banach-space I was doing something similar to what @pzread suggested - https://github.com/tanmaysachan/llvm-project/commit/242f9010fc0b3bf782abcf333b52e1c30121d252 with a base pattern rewriter class that matches on maskop + innerop (contraction inspired by your PR since I'm new to mlir, I was confused how to tackle it otherwise 😅)
@banach-space I was doing something similar to what @pzread suggested - tanmaysachan@242f901 with a base pattern rewriter class that matches on maskop + innerop (contraction inspired by your PR since I'm new to mlir, I was confused how to tackle it otherwise 😅)
I looked at using MaskableOpInterface, but felt that that extra logic/complexity could be avoided. Others might disagree ;-) Regardless, based on your code and comment:
(contraction inspired by your PR since I'm new to mlir, I was confused how to tackle it otherwise 😅)
I think that you should be able to base your changes on top of my PR? IIUC, you are basically generalizing patterns by adding MaskableOpInterface. WDYT?
@banach-space That sounds good to me!