[PATCH] D77965: [mlir][Linalg] NFC: Add utility function to tile, fuse and set marker to use loop.parallel.
Mahesh Ravishankar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 13 13:35:04 PDT 2020
mravishankar updated this revision to Diff 257084.
mravishankar added a comment.
Adding doc comment describing the new utility functions.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D77965/new/
https://reviews.llvm.org/D77965
Files:
mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h
mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp
Index: mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp
===================================================================
--- mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp
+++ mlir/lib/Dialect/Linalg/Transforms/LinalgTransforms.cpp
@@ -40,11 +40,16 @@
const StringLiteral mlir::linalg::LinalgTransforms::kLinalgTransformMarker =
"__internal_linalg_transform__";
-LogicalResult mlir::linalg::tileLinalgOpAndSetMarker(
- PatternRewriter &rewriter, Operation *op, ArrayRef<int64_t> sizes,
- StringRef linalgMarker, ArrayRef<unsigned> permutation) {
+using TileFn = Optional<TiledLinalgOp>(OpBuilder &, LinalgOp, ArrayRef<int64_t>,
+ ArrayRef<unsigned>, OperationFolder *);
+
+static LogicalResult
+tileLinalgOpAndSetMarkerImpl(TileFn tileFn, PatternRewriter &rewriter,
+ Operation *op, ArrayRef<int64_t> sizes,
+ StringRef linalgMarker,
+ ArrayRef<unsigned> permutation) {
assert(permutation.empty() || permutation.size() == sizes.size());
- auto tileRes = tileLinalgOperation(rewriter, op, sizes, permutation);
+ auto tileRes = tileFn(rewriter, op, sizes, permutation, /*folder=*/nullptr);
if (!tileRes)
return failure();
tileRes->op.setAttr(LinalgTransforms::kLinalgTransformMarker,
@@ -52,10 +57,26 @@
return success();
}
-LogicalResult mlir::linalg::tileAndFuseLinalgOpAndSetMarker(
+LogicalResult mlir::linalg::tileLinalgOpAndSetMarker(
PatternRewriter &rewriter, Operation *op, ArrayRef<int64_t> sizes,
- ArrayRef<int64_t> operandIndicesToFuse, StringRef linalgMarker) {
- auto tileRes = tileLinalgOperation(rewriter, op, sizes);
+ StringRef linalgMarker, ArrayRef<unsigned> permutation) {
+ return tileLinalgOpAndSetMarkerImpl(tileLinalgOp, rewriter, op, sizes,
+ linalgMarker, permutation);
+}
+LogicalResult mlir::linalg::tileLinalgOpToParallelLoopsAndSetMarker(
+ PatternRewriter &rewriter, Operation *op, ArrayRef<int64_t> sizes,
+ StringRef linalgMarker, ArrayRef<unsigned> permutation) {
+ return tileLinalgOpAndSetMarkerImpl(tileLinalgOpToParallelLoops, rewriter, op,
+ sizes, linalgMarker, permutation);
+}
+
+static LogicalResult
+tileAndFuseLinalgOpAndSetMarkerImpl(TileFn tileFn, PatternRewriter &rewriter,
+ Operation *op, ArrayRef<int64_t> sizes,
+ ArrayRef<int64_t> operandIndicesToFuse,
+ StringRef linalgMarker) {
+ auto tileRes =
+ tileFn(rewriter, op, sizes, /*permutation=*/{}, /*folder=*/nullptr);
if (!tileRes)
return failure();
tileRes->op.setAttr(LinalgTransforms::kLinalgTransformMarker,
@@ -89,6 +110,20 @@
return success();
}
+LogicalResult mlir::linalg::tileAndFuseLinalgOpAndSetMarker(
+ PatternRewriter &rewriter, Operation *op, ArrayRef<int64_t> sizes,
+ ArrayRef<int64_t> operandIndicesToFuse, StringRef linalgMarker) {
+ return tileAndFuseLinalgOpAndSetMarkerImpl(
+ tileLinalgOp, rewriter, op, sizes, operandIndicesToFuse, linalgMarker);
+}
+LogicalResult mlir::linalg::tileAndFuseLinalgOpToParallelLoopsAndSetMarker(
+ PatternRewriter &rewriter, Operation *op, ArrayRef<int64_t> sizes,
+ ArrayRef<int64_t> operandIndicesToFuse, StringRef linalgMarker) {
+ return tileAndFuseLinalgOpAndSetMarkerImpl(
+ tileLinalgOpToParallelLoops, rewriter, op, sizes, operandIndicesToFuse,
+ linalgMarker);
+}
+
bool mlir::linalg::detail::isProducedByOpOfTypeImpl(
Operation *consumerOp, Value consumedView,
function_ref<bool(Operation *)> isaOpType) {
Index: mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h
===================================================================
--- mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h
+++ mlir/include/mlir/Dialect/Linalg/Transforms/LinalgTransforms.h
@@ -63,12 +63,18 @@
ArrayRef<int64_t> sizes,
StringRef linalgMarker,
ArrayRef<unsigned> permutation);
+LogicalResult tileLinalgOpToParallelLoopsAndSetMarker(
+ PatternRewriter &rewriter, Operation *op, ArrayRef<int64_t> sizes,
+ StringRef linalgMarker, ArrayRef<unsigned> permutation);
/// Tiles `op` by `sizes`, fuses the producers of `operandIndicesToFuse` and
/// sets the attribute `kLinalgTransformMarker` to `linalgMarker`.
LogicalResult tileAndFuseLinalgOpAndSetMarker(
PatternRewriter &rewriter, Operation *op, ArrayRef<int64_t> sizes,
ArrayRef<int64_t> operandIndicesToFuse, StringRef linalgMarker);
+LogicalResult tileAndFuseLinalgOpToParallelLoopsAndSetMarker(
+ PatternRewriter &rewriter, Operation *op, ArrayRef<int64_t> sizes,
+ ArrayRef<int64_t> operandIndicesToFuse, StringRef linalgMarker);
using LinalgLoops = SmallVector<Operation *, 4>;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77965.257084.patch
Type: text/x-patch
Size: 4995 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200413/998623e3/attachment.bin>
More information about the llvm-commits
mailing list