[Mlir-commits] [mlir] [mlir][vector] Fix parser of vector.transfer_read (PR #133721)

Andrzej WarzyƄski llvmlistbot at llvm.org
Wed Apr 2 05:52:10 PDT 2025


================
@@ -4668,6 +4677,11 @@ ParseResult TransferWriteOp::parse(OpAsmParser &parser,
   AffineMap permMap;
   if (!permMapAttr) {
     permMap = getTransferMinorIdentityMap(shapedType, vectorType);
+    if (!permMap) {
+      return parser.emitError(typesLoc,
+                              "expected the same rank for the vector and the "
+                              "results of the permutation map");
----------------
banach-space wrote:

This is documenting _why_ `getTransferMinorIdentityMap` has failed without checking any error codes. This error will be out-of-date should `getTransferMinorIdentityMap` start failing for other reasons.

I recommend a more generic error msg, e.g. "failed to create a minor identity map". 

On a related note, it feels that we should make this example fail much earlier:
```mlir
  %0 = vector.transfer_read %arg1[%c3_i32, %c3_i32], %c3_i32 : memref<?xindex>, vector<3x4xi32>
```

So I am also thinking that this would make more sense:
```cpp
    if (!permMapAttr) {
      if (shapedType.getRank() < vectorType.getRank() - elementVectorRank) {
        return parser.emitError(typesLoc,
                                "In the absence of a permutation map, expected (...)");
     }                             
```

First, let's see what's the answer re `elementVectorRank` (see my question in the other thread).

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


More information about the Mlir-commits mailing list