[Mlir-commits] [mlir] 1edfb4b - [mlir][Linalg] Allow linalg.copy to be vectorized with masking
Nicolas Vasilache
llvmlistbot at llvm.org
Wed Apr 12 05:35:23 PDT 2023
Author: Nicolas Vasilache
Date: 2023-04-12T05:35:17-07:00
New Revision: 1edfb4b93d33d04dd042d6f5a140e438b98b2424
URL: https://github.com/llvm/llvm-project/commit/1edfb4b93d33d04dd042d6f5a140e438b98b2424
DIFF: https://github.com/llvm/llvm-project/commit/1edfb4b93d33d04dd042d6f5a140e438b98b2424.diff
LOG: [mlir][Linalg] Allow linalg.copy to be vectorized with masking
Differential Revision: https://reviews.llvm.org/D148095
Added:
Modified:
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
mlir/test/Dialect/Linalg/vectorization.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
index ebfddbe00d07..b54eb0fa9a4f 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
@@ -1282,7 +1282,7 @@ static LogicalResult reductionPreconditions(LinalgOp op) {
static LogicalResult vectorizeDynamicLinalgOpPrecondition(linalg::LinalgOp op) {
// TODO: Masking only supports dynamic generic ops for now.
- if (!isa<linalg::GenericOp, linalg::FillOp>(op))
+ if (!isa<linalg::GenericOp, linalg::FillOp, linalg::CopyOp>(op))
return failure();
LDBG("Dynamically-shaped op meets vectorization pre-conditions\n");
diff --git a/mlir/test/Dialect/Linalg/vectorization.mlir b/mlir/test/Dialect/Linalg/vectorization.mlir
index a023307fbd16..c407b49d896c 100644
--- a/mlir/test/Dialect/Linalg/vectorization.mlir
+++ b/mlir/test/Dialect/Linalg/vectorization.mlir
@@ -2737,3 +2737,23 @@ transform.sequence failures(propagate) {
transform.structured.masked_vectorize %0 vector_sizes [8, 16]
}
+// -----
+
+// CHECK-LABEL: func @test_masked_vectorize_linalg_copy
+func.func @test_masked_vectorize_linalg_copy(%A : memref<?x?xf32>, %B : memref<?x?xf32>) {
+ // CHECK: %[[c0:.*]] = arith.constant 0 : index
+ // CHECK: %[[d0:.*]] = memref.dim %{{.*}}, %[[c0]] : memref<?x?xf32>
+ // CHECK: %[[c1:.*]] = arith.constant 1 : index
+ // CHECK: %[[d1:.*]] = memref.dim %{{.*}}, %[[c1]] : memref<?x?xf32>
+ // CHECK: %[[mask:.*]] = vector.create_mask %[[d0]], %[[d1]] : vector<2x4xi1>
+ // CHECK: vector.mask %[[mask]] {{.*}} vector.transfer_read %{{.*}} {in_bounds = [true, true]} : memref<?x?xf32>, vector<2x4xf32> } : vector<2x4xi1> -> vector<2x4xf32>
+ // CHECK: vector.mask %[[mask]] {{.*}} vector.transfer_write %{{.*}} {in_bounds = [true, true]} : vector<2x4xf32>, memref<?x?xf32> } : vector<2x4xi1>
+ linalg.copy ins(%A : memref<?x?xf32>) outs(%B : memref<?x?xf32>)
+ return
+}
+
+transform.sequence failures(propagate) {
+^bb1(%arg1: !pdl.operation):
+ %0 = transform.structured.match ops{["linalg.copy"]} in %arg1 : (!pdl.operation) -> !pdl.operation
+ transform.structured.masked_vectorize %0 vector_sizes [2, 4]
+}
More information about the Mlir-commits
mailing list