This commit enables DRR rewriter to match a fixed number of sub-operands as a variadic operand:
def : Pat<(ConcatenateOp (variadic $input0, $input1)), (SomeOtherOp $input0, $input1)>;
Paths
| Differential D157359
[mlir] Enable DRR variadic operand matching ClosedPublic Authored by logan on Aug 7 2023, 9:30 PM.
Details Summary This commit enables DRR rewriter to match a fixed number of sub-operands as a variadic operand: def : Pat<(ConcatenateOp (variadic $input0, $input1)), (SomeOtherOp $input0, $input1)>;
Diff Detail Event TimelineComment Actions LGTM, given that I'm not currently working on MLIR. Will leave @jpienaar to make the decision
Comment Actions Nice, so this is a more refined variant of https://reviews.llvm.org/D121046 that enables more general support? Comment Actions
Kind of. This enables the sub-dag pattern matching into a variadic operand and checks HasExactValues<n> automatically. It also avoids the need of Front and DropFront sequences. However, the limitation of this approach is that I only match variadic operand with exactly N sub-trees. I don't support "N sub-tree + tails". Technically doable by defining a (variantFrontNAndTails $sub0, $sub1, ..., $sub_n_m1, $tails) where $tails matches the remaining range. But to keep this simple, I didn't implement variantFrontNAndTails. Comment Actions Changes in Revision 2:
logan marked 3 inline comments as done. Comment ActionsChanges in Revision 3:
logan added inline comments.
Comment Actions Does variadic also work in the target dag?
Comment Actions
No, this commit doesn't support that. I couldn't figure it out at this moment.
This revision is now accepted and ready to land.Aug 28 2023, 12:40 PM
Revision Contents
Diff 552213 mlir/docs/DeclarativeRewrites.md
mlir/include/mlir/IR/PatternBase.td
mlir/include/mlir/TableGen/Pattern.h
mlir/lib/TableGen/Pattern.cpp
mlir/test/lib/Dialect/Test/TestOps.td
mlir/test/mlir-tblgen/pattern.mlir
mlir/tools/mlir-tblgen/RewriterGen.cpp
|
space?