[Mlir-commits] [mlir] [mlir][memref.expand_shape] Add verifier check to ensure correct output_shape is provided by user (PR #91245)

Mehdi Amini llvmlistbot at llvm.org
Tue May 7 02:56:47 PDT 2024


================
@@ -2353,6 +2353,16 @@ LogicalResult ExpandShapeOp::verify() {
            << " dynamic dims while output_shape has " << getOutputShape().size()
            << " values";
 
+  // 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 (unsigned i = 0, e = resShape.size(); i < e; ++i)
----------------
joker-eph wrote:

Most modern loop over indices would be this right now:

```suggestion
  for (int i = : llvm::seq<int>(0, resShape.size())
```

But the enumerate may even be nicer:

```suggestion
  for (auto [pos, shape] : llvm::enumerate(resShape))
```

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


More information about the Mlir-commits mailing list