[Mlir-commits] [mlir] [mlir][Vectorizer] Added support to Vectorize tensor.unpack (PR #76087)

Han-Chung Wang llvmlistbot at llvm.org
Tue Feb 6 21:15:47 PST 2024


================
@@ -1393,6 +1394,130 @@ vectorizeAsLinalgGeneric(RewriterBase &rewriter, VectorizationState &state,
   return success();
 }
 
+/// Vectorize an `tensor::UnPackOp` without OuterDimsPerms to these 4 Ops:
+///   Vector::TransferReadOp - Reads the Vector Array of Source data
+///   vector::TransposeOp - Transpose the Source
+///   ShapeCastOp - Reshapes the data based on the target.
+///   vector::TransferWriteOp. - Write the result vector back.
+static LogicalResult vectorizeAsUnpackOp(RewriterBase &rewriter,
+                                         tensor::UnPackOp unpackOp,
+                                         ArrayRef<int64_t> inputVectorSizes,
+                                         SmallVectorImpl<Value> &newResults) {
+  // Handling this case requires a bit more change. Right now
+  // just the required attributes are handled.
+  if (!unpackOp.getOuterDimsPerm().empty()) {
+    LDBG("outer dimensions perms NYI for: " << unpackOp);
+    return failure();
+  }
----------------
hanhanW wrote:

This should be moved to `vectorizeUnPackOpPreCondition` like what we've done for other linalg ops.

https://github.com/llvm/llvm-project/blob/8ea7f1d20ad8ab8c381800eefda948d85c6860cc/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp#L1453-L1484

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


More information about the Mlir-commits mailing list