[Mlir-commits] [mlir] [mlir][linalg] Fix Linalg runtime verification pass to handle tensors with dimensions of size 0 (PR #163791)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Oct 20 14:09:51 PDT 2025


================
@@ -43,6 +44,32 @@ struct StructuredOpInterface
     auto zero = arith::ConstantIndexOp::create(builder, loc, 0);
     auto one = arith::ConstantIndexOp::create(builder, loc, 1);
 
+    Value iterationDomainIsNonDegenerate;
+    for (auto [start, end] : llvm::zip(starts, ends)) {
+      auto startValue = getValueOrCreateConstantIndexOp(builder, loc, start);
+      auto endValue = getValueOrCreateConstantIndexOp(builder, loc, end);
+
+      // Loop Trip count > 0 iff start < end
+      Value dimensionHasNonZeroTripCount = builder.create<index::CmpOp>(
+          loc, index::IndexCmpPredicate::SLT, startValue, endValue);
+
+      if (!iterationDomainIsNonDegenerate) {
+        iterationDomainIsNonDegenerate = dimensionHasNonZeroTripCount;
+      } else {
+        // Iteration domain is non-degenerate iff all dimensions have loop trip
+        // count > 0
+        iterationDomainIsNonDegenerate = builder.create<arith::AndIOp>(
----------------
Hanumanth04 wrote:

It should be `AndIOp` as we skip verification if any of the dimensions is empty.

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


More information about the Mlir-commits mailing list