We can fold redundant Tosa::TransposeOp actions like identity tranpose/transpose(traspose).
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Overall move the double tosa.transpose pattern to a TOSA canonicalization pattern, then replace with a
new tosa.transpose op. We can leverage the existing tosa.transpose folder to remove the extra operation
if it is a standard version.
mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp | ||
---|---|---|
957 | Breaking this out to a separate function is unnecessary as the folder should focus on the simple case. | |
981 | This is better handled by adding a TransposeOp + TransposeOp -> TransposeOp canonicalization pattern. This allows multiple transposes to merge together, then reuse the existing folder to remove the noop version. | |
983 | We avoid putting multi-op folders together as folding patterns should avoid becoming cumbersome. These kind of operations should stick to canonicalizers. |
I appreciate your code review! Can you please review my new revision?
Thanks,
Aviad
mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp | ||
---|---|---|
957 | This function is still usefull both in TransposeOp::fold & in ConsolidateTransposeOptimization::matchAndRewrite , I think can usefull, can you check the new revision? | |
981 | Good idea, adjusted the code according to your suggestion. | |
983 | Ack. |
mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp | ||
---|---|---|
144 | return rewriter.notifyMatchFailure(op, <error message>); | |
144–145 | Include error message. | |
151 | Use ++i instead of i++. | |
957 |
The problem is you have no way to discern if the perms is a constant value of size-0 or a non-constant value. Typically we avoid cases like returning an empty array as a failure sign to avoid ambiguous returns. | |
1021 | Missing newline. | |
mlir/test/IR/transpose-fold.mlir | ||
47 | Missing newline. |
Hi Rob,
I fixed the adidiotnal comments.
Thanks,
Aviad Cohen
mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp | ||
---|---|---|
144 | Good point, updated to importmative error messages. | |
144–145 | Updated to importmative error messages. | |
151 | Ack. | |
957 | Right. I updated the function to return a LogicalResult when failed. | |
1021 | Ack. | |
mlir/test/IR/transpose-fold.mlir | ||
47 | Ack. |
return rewriter.notifyMatchFailure(op, <error message>);