[Mlir-commits] [mlir] Fix `memref.expand_shape` verifier (PR #91501)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed May 8 09:36:24 PDT 2024


================
@@ -2356,12 +2356,11 @@ LogicalResult ExpandShapeOp::verify() {
   // Verify if provided output shapes are in agreement with output type.
   DenseI64ArrayAttr staticOutputShapes = getStaticOutputShapeAttr();
   ArrayRef<int64_t> resShape = getResult().getType().getShape();
-  unsigned staticShapeNum = 0;
-
-  for (auto [pos, shape] : llvm::enumerate(resShape))
-    if (!ShapedType::isDynamic(shape) &&
-        shape != staticOutputShapes[staticShapeNum++])
+  for (auto [pos, shape] : llvm::enumerate(resShape)) {
+    if (!ShapedType::isDynamic(shape) && shape != staticOutputShapes[pos]) {
       emitOpError("invalid output shape provided at pos ") << pos;
+    }
----------------
MaheshRavishankar wrote:

The format as IIUC the `output_shape` is a mix of static and dynamic. So you should be able to try
```
 %r = memref.expand_shape %0 [[0, 1], [2]] output_shape [%sz0, %sz1, 16]
        : memref<?x32xf32> into memref<?x?x32xf32>
```
to check (hopefully)

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


More information about the Mlir-commits mailing list