From: gysit Date: Mon, 6 Dec 2021 07:25:24 +0000 (+0000) Subject: [mlir][linalg] Pad independent of application order (NFC). X-Git-Tag: upstream/15.0.7~23928 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69bcff46bff34838c91880ecaa6616bb6979cd23;p=platform%2Fupstream%2Fllvm.git [mlir][linalg] Pad independent of application order (NFC). This revision makes the padding pattern independent of the application order. It addresses the concern that we cannot rely on the execution order of the greedy rewriter (https://reviews.llvm.org/D114689). Instead, the pattern is updated to apply repeatedly till all operations are padded. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D114851 --- diff --git a/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp b/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp index c006a1e77801..0da17434c429 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp @@ -132,19 +132,7 @@ struct LinalgStrategyPadPass paddingPattern.add(funcOp.getContext(), options, filter); } - // Traverse the operations top down to pad producers before consumers. The - // extract slice operation introduced after every padded operation enables - // padding its consumers. Padding an operation whose producers have not been - // padded before fails due to the missing extract slice operations. In this - // case, the padding pattern increments the transformation marker without - // padding the operation. The top down traversal is thus not only a - // performance optimization but also needed to pad all operations along the - // use-def chains. - GreedyRewriteConfig config; - config.useTopDownTraversal = true; - if (failed(applyPatternsAndFoldGreedily(funcOp, std::move(paddingPattern), - config))) - signalPassFailure(); + (void)applyPatternsAndFoldGreedily(funcOp, std::move(paddingPattern)); } LinalgPaddingOptions options; diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp index 917ff770a3b5..e2d16cf285d3 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp @@ -503,10 +503,8 @@ LogicalResult mlir::linalg::LinalgPaddingPattern::matchAndRewrite( FailureOr> newResults = rewriteAsPaddedOp( rewriter, linalgOp, options.paddingValueComputationFunction, options.paddingNoFoldComputationFunction, paddedOp); - if (failed(newResults)) { - filter.replaceLinalgTransformationFilter(rewriter, linalgOp); + if (failed(newResults)) return failure(); - } // Compute the desired hoisting depths. SmallVector depths;