[Mlir-commits] [mlir] [mlir][vector] Fix parser of vector.transfer_read (PR #133721)
Andrzej WarzyĆski
llvmlistbot at llvm.org
Mon Apr 7 10:35:07 PDT 2025
================
@@ -152,18 +152,22 @@ static bool isSupportedCombiningKind(CombiningKind combiningKind,
AffineMap mlir::vector::getTransferMinorIdentityMap(ShapedType shapedType,
VectorType vectorType) {
- int64_t elementVectorRank = 0;
- VectorType elementVectorType =
- llvm::dyn_cast<VectorType>(shapedType.getElementType());
- if (elementVectorType)
- elementVectorRank += elementVectorType.getRank();
// 0-d transfers are to/from tensor<t>/memref<t> and vector<1xt>.
// TODO: replace once we have 0-d vectors.
if (shapedType.getRank() == 0 &&
vectorType.getShape() == ArrayRef<int64_t>{1})
return AffineMap::get(
/*numDims=*/0, /*numSymbols=*/0,
getAffineConstantExpr(0, shapedType.getContext()));
+ int64_t elementVectorRank = 0;
+ VectorType elementVectorType =
+ llvm::dyn_cast<VectorType>(shapedType.getElementType());
+ if (elementVectorType)
+ elementVectorRank += elementVectorType.getRank();
+ if (shapedType.getRank() < vectorType.getRank() - elementVectorRank) {
+ // Not enough dimensions in the shaped type to form a minor identity map.
+ return AffineMap();
+ }
----------------
banach-space wrote:
I think that you can restore it back to the top and also add an `assert` instead of `return AffineMap()`:
```suggestion
int64_t elementVectorRank = 0;
VectorType elementVectorType =
llvm::dyn_cast<VectorType>(shapedType.getElementType());
if (elementVectorType)
elementVectorRank += elementVectorType.getRank();
assert(shapedType.getRank() < vectorType.getRank() - elementVectorRank && "Not enough dimensions in the shaped type to form a minor identity map.")
}
```
https://github.com/llvm/llvm-project/pull/133721
More information about the Mlir-commits
mailing list