[Mlir-commits] [mlir] [mlir][vector] Fix off-by-one error in `getTransferChunkAccessed` (PR #70292)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Oct 25 22:32:47 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Matthias Springer (matthias-springer)
<details>
<summary>Changes</summary>
If a dimension does not appear in the permutation map of a vector transfer op, the size of the accessed slice in that dimension is `1`. Before this fix, `getTransferChunkAccessed` used to return `0` for such dimensions, which would means that `0` elements in the underlying tensor/memref are accessed.
---
Full diff: https://github.com/llvm/llvm-project/pull/70292.diff
1 Files Affected:
- (modified) mlir/include/mlir/Interfaces/VectorInterfaces.td (+7-7)
``````````diff
diff --git a/mlir/include/mlir/Interfaces/VectorInterfaces.td b/mlir/include/mlir/Interfaces/VectorInterfaces.td
index 346a409a3f3e0ef..026faf269f368de 100644
--- a/mlir/include/mlir/Interfaces/VectorInterfaces.td
+++ b/mlir/include/mlir/Interfaces/VectorInterfaces.td
@@ -257,22 +257,22 @@ def VectorTransferOpInterface : OpInterface<"VectorTransferOpInterface"> {
>,
InterfaceMethod<
/*desc=*/[{
- Return an upper-bound shape accessed by the transfer op within the
- tensor/memref operand.
+ Return the shape of the hyperrectangular slice within the tensor/memref
+ operand that is accessed by the transfer op.
For example:
```
- vector.transfer %w0[%i, %j] {
- permutation_map = affine_map<(d0, d1) -> (d1, d0, 0)>} :
- tensor<?x?xf32>, vector<4x2x6xf32>
+ vector.transfer %w0[%i, %j, %k] {
+ permutation_map = affine_map<(d0, d1, d2) -> (d1, d0, 0)>} :
+ tensor<?x?x?xf32>, vector<4x2x6xf32>
```
- returns a shape [2, 4].
+ returns a shape [2, 4, 1].
}],
/*retTy=*/"SmallVector<int64_t>",
/*methodName=*/"getTransferChunkAccessed",
/*args=*/(ins),
/*methodBody=*/"",
/*defaultImplementation=*/[{
- SmallVector<int64_t> dimSizes($_op.getPermutationMap().getNumDims(), 0);
+ SmallVector<int64_t> dimSizes($_op.getPermutationMap().getNumDims(), 1);
for (auto vecDims : llvm::zip($_op.getPermutationMap().getResults(),
$_op.getVectorType().getShape())) {
AffineExpr dim = std::get<0>(vecDims);
``````````
</details>
https://github.com/llvm/llvm-project/pull/70292
More information about the Mlir-commits
mailing list