Skip to content

Commit 598106d

Browse files
[mlir][Linalg] NFC: Expose a method to deduplicate operands/remove dead results of linalg.generic op. (#125141)
This functionality was wrapped within a pattern. Expose this as a separate transformations function that can be used outside of pattern rewrite mechanism. --------- Signed-off-by: MaheshRavishankar <[email protected]>
1 parent 280609c commit 598106d

File tree

2 files changed

+249
-231
lines changed

2 files changed

+249
-231
lines changed

mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,14 @@ FailureOr<Operation *>
13951395
decomposeWinogradOutputTransformOp(RewriterBase &rewriter,
13961396
linalg::WinogradOutputTransformOp op);
13971397

1398+
/// Method to deduplicate operands and remove dead results of `linalg.generic`
1399+
/// operations. This is effectively DCE for a linalg.generic op. If there is
1400+
/// deduplication of operands orremoval of results, replaces the `genericOp`
1401+
/// with a new op and returns it. Returns the same operation if there is no
1402+
/// deduplication/removal.
1403+
FailureOr<linalg::GenericOp> deduplicateOperandsAndRemoveDeadResults(
1404+
RewriterBase &rewriter, linalg::GenericOp genericOp, bool removeOutputs);
1405+
13981406
//===----------------------------------------------------------------------===//
13991407
// Rewrite patterns wrapping transformations.
14001408
// TODO: every single such pattern should be a close to noop wrapper around a
@@ -1786,7 +1794,7 @@ void populateDataLayoutPropagationPatterns(
17861794
const ControlPropagationFn &controlPackUnPackPropagation);
17871795

17881796
/// Pattern to remove dead operands and results of `linalg.generic` operations.
1789-
/// This is effectively DCE for a linalg op.
1797+
/// This is a pattern wrapper for `deduplicateOperandsAndRemoveDeadResults`.
17901798
void populateEraseUnusedOperandsAndResultsPatterns(RewritePatternSet &patterns);
17911799

17921800
/// Patterns to promote inputs to outputs and remove unused inputs of

0 commit comments

Comments
 (0)