[Mlir-commits] [mlir] [mlir][linalg] Vectorize unpack op without masking (PR #89067)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Fri May 3 07:42:08 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.
----------------
banach-space wrote:
```suggestion
// 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
// source tensor is rank 'M' and the dest tensor is rank 'N', where N <= M.
// Thus:
// 1. vectorSizes = sourceShape.take_front(N)
// 2. if outer_dims_perms is present: do that permutation on vectorSizes.
// 3. multiply all the locations in VectorSize pointed by innerDimPos by the innerTiles
// attribute value.
```
1. Remove references to `initVectorShape`
2. This sentence doesn't make sense when `vectorSizes` is empty: "the vectorSize (VS) array is size 'N'". That's fine - I think what's more important is the rank of the source tensor (`M`) and the output tensor (`N`).
3. Consistent capitalisation (nit)
4. Use numbering to highlight that these are consecutive steps (nit)
https://github.com/llvm/llvm-project/pull/89067
More information about the Mlir-commits
mailing list