[Mlir-commits] [mlir] [mlir][vector] Fix off-by-one error in `getTransferChunkAccessed` (PR #70292)
Matthias Springer
llvmlistbot at llvm.org
Wed Oct 25 22:31:38 PDT 2023
https://github.com/matthias-springer created https://github.com/llvm/llvm-project/pull/70292
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.
>From fe02bc33a31231aefc839746dd6c0a18bd2ce883 Mon Sep 17 00:00:00 2001
From: Matthias Springer <springerm at google.com>
Date: Thu, 26 Oct 2023 14:29:51 +0900
Subject: [PATCH] [mlir][vector] Fix off-by-one error in
`getTransferChunkAccessed`
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.
---
mlir/include/mlir/Interfaces/VectorInterfaces.td | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
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);
More information about the Mlir-commits
mailing list