This allows assuming_all to be replaced when all inputs are known to be
statically passing witnesses.
Details
Details
- Reviewers
jpienaar silvas herhut - Commits
- rG6b3a5bff93cd: [mlir] Folding of shape.assuming_all
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
LGTM, but let's look into using a fold for this (the good thing is that all the test cases will carry over :) )
mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td | ||
---|---|---|
1 ↗ | (On Diff #265270) | Missing file header? |
4 ↗ | (On Diff #265270) | Could we indent by 2 instead? def AllInputsTrueWitnesses : Constraint<CPred<[ llvm::all_of($0.getOwner()->getOperands(), [](mlir::Value op) { return op.getDefiningOp<mlir::shape::TrueWitnessOp>(); })}]>>; |
12 ↗ | (On Diff #265270) | Could we just indent these by 2 instead? [yes we need a formatter ... and many other variants as below] def ConstantAssumingAll : Pat< (Shape_AssumingAllOp:$op $input), (Shape_TrueWitnessOp), [(AllInputsTrueWitnesses $op)]>; |
Comment Actions
Feel free to land. Comments are just suggestions and can also be addressed in a follow up.
mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td | ||
---|---|---|
6 ↗ | (On Diff #265270) | This would be a great place to use the isTrueWitness helper. |
11 ↗ | (On Diff #265270) | This could also be formulated as a pattern that drops constant true witnesses from the operands and a pattern that replaces an assuming_all with no operands by a constant true witness. That way we also get removal of constant operands (which is more a cosmetic cleanup and does not really propagate any knowledge). |