[Mlir-commits] [mlir] [mlir] ViewLikeInterface - verify ranks in verifyOffsetSizeAndStrideOp (PR #147926)

Matthias Springer llvmlistbot at llvm.org
Thu Jul 10 05:15:11 PDT 2025


================
@@ -94,6 +94,32 @@ SliceBoundsVerificationResult mlir::verifyInBoundsSlice(
 
 LogicalResult
 mlir::detail::verifyOffsetSizeAndStrideOp(OffsetSizeAndStrideOpInterface op) {
+  // A dynamic size is represented as ShapedType::kDynamic in `static_sizes`.
+  // Its corresponding Value appears in `sizes`. Thus, the number of dynamic
+  // dimensions in `static_sizes` must equal the rank of `sizes`.
+  // The same applies to strides and offsets.
+  unsigned int numDynamicDims =
+      llvm::count_if(op.getStaticSizes(), ShapedType::isDynamic);
+  if (op.getSizes().size() != numDynamicDims) {
+    return op->emitError("expected sizes rank to match the number of dynamic "
----------------
matthias-springer wrote:

nit: I wouldn't use the term "rank" because users may think of the rank of the source

e.g.:
```
expected the number of 'sizes' to match the number of dynamic entries in 'static_sizes'
```


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


More information about the Mlir-commits mailing list