[Mlir-commits] [mlir] [mlir][vector] Patterns to convert to shape_cast, where possible (PR #138777)

Han-Chung Wang llvmlistbot at llvm.org
Wed May 7 11:20:37 PDT 2025


================
@@ -2182,6 +2182,92 @@ struct FoldArithToVectorOuterProduct : public OpRewritePattern<MulOpType> {
   }
 };
 
+/// For example,
+/// ```
+/// %0 = vector.transpose %arg0, [0, 2, 1] :
+///                   vector<2x1x2xf32> to vector<2x2x1xf32>
+/// ```
+/// becomes
+/// ```
+/// %0 = vector.shape_cast %arg0 :
+///                   vector<2x1x2xf32> to vector<2x2x1xf32>
+/// ```
+struct TransposeToShapeCast final
----------------
hanhanW wrote:

We might want to clean up other patterns because we have a similar pattern but just for 2D vectors. Please coordinate with @banach-space about scalable vector for the support.

https://github.com/llvm/llvm-project/blob/8810595068a3f17c444e7f96733a6cd9dc08987e/mlir/lib/Dialect/Vector/Transforms/LowerVectorTranspose.cpp#L385-L441



https://github.com/llvm/llvm-project/pull/138777


More information about the Mlir-commits mailing list