[Mlir-commits] [mlir] [mlir][linalg] Vectorize unpack op without masking (PR #89067)

Prashant Kumar llvmlistbot at llvm.org
Fri May 3 08:04:48 PDT 2024


================
@@ -1560,40 +1575,61 @@ vectorizeAsTensorUnpackOp(RewriterBase &rewriter, tensor::UnPackOp unpackOp,
 
   ArrayRef<int64_t> innerDimPos = unpackOp.getInnerDimsPos();
   ArrayRef<int64_t> innerTiles = unpackOp.getStaticInnerTiles();
-
-  SmallVector<int64_t> readMaskShape(inputVectorSizes.begin(),
-                                     inputVectorSizes.end());
-  ArrayRef<int64_t> outerDimsPerm = unpackOp.getOuterDimsPerm();
   ArrayRef<int64_t> sourceShape = unpackTensorType.getShape();
+  bool useInBoundsInsteadOfMasking = false;
+  ArrayRef<int64_t> outerDimsPerm = unpackOp.getOuterDimsPerm();
+
+  auto destSize = unpackOp.getDestRank();
 
-  // ReadMask is the size of tensor used to read and apply mask. It is
+  // vectorSizes is the shape of the vector that will be used to do final
+  // write on the destination tensor. It is set like this: Let's say the
+  // sourceShape is 'M' and the vectorSize (VS) array is size 'N' where N <= M.
+  // Thus:
+  // - vectorSizes = sourceShape.take_front(N)
+  // - if outer_dims_perms is present: do that permutation on initVectorShape.
+  // - Multiply all the locations pointed by innerDimPos by the innerTileSize
+  //  attribute value.
+  SmallVector<int64_t> vectorSizes(inputVectorSizes);
----------------
pashu123 wrote:

1. There's actually a check performed here: https://github.com/llvm/llvm-project/blob/64013f94eaea2f0e1bf752cc1ffec3989f07d358/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp#L1676. Only if the destination type is static can we use vectorSizes; otherwise, we resort to something else.
2. check is performed here: https://github.com/llvm/llvm-project/blob/64013f94eaea2f0e1bf752cc1ffec3989f07d358/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp#L1798

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


More information about the Mlir-commits mailing list