[Mlir-commits] [mlir] [mlir][vector] Disable transpose -> shuffle lowering for scalable vectors (PR #79979)

Benjamin Maxwell llvmlistbot at llvm.org
Tue Jan 30 03:00:56 PST 2024


https://github.com/MacDue created https://github.com/llvm/llvm-project/pull/79979

vector.shuffle is not supported for scalable vectors (outside of splats)

>From 7d05a932f8be151d5cc5906f9a594feb2248fa9d Mon Sep 17 00:00:00 2001
From: Benjamin Maxwell <benjamin.maxwell at arm.com>
Date: Tue, 30 Jan 2024 10:55:31 +0000
Subject: [PATCH] [mlir][vector] Disable transpose -> shuffle lowering for
 scalable vectors

vector.shuffle is not supported for scalable vectors (outside of splats)
---
 .../Transforms/LowerVectorTranspose.cpp       |  4 ++++
 .../Vector/vector-transpose-lowering.mlir     | 21 +++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/mlir/lib/Dialect/Vector/Transforms/LowerVectorTranspose.cpp b/mlir/lib/Dialect/Vector/Transforms/LowerVectorTranspose.cpp
index 97f6caca1b25c..792550dcfaf22 100644
--- a/mlir/lib/Dialect/Vector/Transforms/LowerVectorTranspose.cpp
+++ b/mlir/lib/Dialect/Vector/Transforms/LowerVectorTranspose.cpp
@@ -434,6 +434,10 @@ class TransposeOp2DToShuffleLowering
       return rewriter.notifyMatchFailure(
           op, "not using vector shuffle based lowering");
 
+    if (op.getSourceVectorType().isScalable())
+      return rewriter.notifyMatchFailure(
+          op, "vector shuffle lowering not supported for scalable vectors");
+
     auto srcGtOneDims = isTranspose2DSlice(op);
     if (failed(srcGtOneDims))
       return rewriter.notifyMatchFailure(
diff --git a/mlir/test/Dialect/Vector/vector-transpose-lowering.mlir b/mlir/test/Dialect/Vector/vector-transpose-lowering.mlir
index c0b44428d5bcf..97b698edeb059 100644
--- a/mlir/test/Dialect/Vector/vector-transpose-lowering.mlir
+++ b/mlir/test/Dialect/Vector/vector-transpose-lowering.mlir
@@ -849,3 +849,24 @@ module attributes {transform.with_named_sequence} {
     transform.yield
   }
 }
+
+// -----
+
+// Scalable transposes should not be lowered to vector.shuffle.
+
+// CHECK-LABEL: func @transpose_nx8x2xf32
+func.func @transpose_nx8x2xf32(%arg0: vector<[8]x2xf32>) -> vector<2x[8]xf32> {
+  // CHECK-NOT: vector.shuffle
+  // CHECK: vector.transpose %{{.*}} : vector<[8]x2xf32> to vector<2x[8]xf32>
+  %0 = vector.transpose %arg0, [1, 0] : vector<[8]x2xf32> to vector<2x[8]xf32>
+  return %0 : vector<2x[8]xf32>
+}
+
+module attributes {transform.with_named_sequence} {
+  transform.named_sequence @__transform_main(%func_op: !transform.op<"func.func"> {transform.readonly}) {
+    transform.apply_patterns to %func_op {
+      transform.apply_patterns.vector.lower_transpose lowering_strategy = "shuffle_1d"
+    } : !transform.op<"func.func">
+    transform.yield
+  }
+}



More information about the Mlir-commits mailing list