[Mlir-commits] [mlir] [mlir][tensor] Add runtime verification for expand_shape/concat/reshape (PR #236783)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Oct 29 06:48:25 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- mlir/lib/Dialect/Tensor/IR/TensorDialect.cpp mlir/lib/Dialect/Tensor/Transforms/RuntimeOpVerification.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/lib/Dialect/Tensor/Transforms/RuntimeOpVerification.cpp b/mlir/lib/Dialect/Tensor/Transforms/RuntimeOpVerification.cpp
index 3a0fb3525..da5833657 100644
--- a/mlir/lib/Dialect/Tensor/Transforms/RuntimeOpVerification.cpp
+++ b/mlir/lib/Dialect/Tensor/Transforms/RuntimeOpVerification.cpp
@@ -359,9 +359,8 @@ struct ConcatOpInterface
                                   getDimSize(input, concatDim));
     Value resultSize = arith::ConstantIndexOp::create(
         builder, loc, resultType.getDimSize(concatDim));
-    Value isEqual = arith::CmpIOp::create(builder, loc,
-                                          arith::CmpIPredicate::eq, sum,
-                                          resultSize);
+    Value isEqual = arith::CmpIOp::create(
+        builder, loc, arith::CmpIPredicate::eq, sum, resultSize);
     cf::AssertOp::create(
         builder, loc, isEqual,
         generateErrorMessage(op, "sum of input sizes along concatenated "
@@ -394,8 +393,8 @@ struct ReshapeOpInterface
       Value shapeValue =
           ExtractOp::create(builder, loc, reshapeOp.getShape(), idx);
       if (shapeValue.getType() != indexType)
-        shapeValue = arith::IndexCastOp::create(builder, loc, indexType,
-                                                shapeValue);
+        shapeValue =
+            arith::IndexCastOp::create(builder, loc, indexType, shapeValue);
       shapeValues.push_back(shapeValue);
     }
 
@@ -410,9 +409,9 @@ struct ReshapeOpInterface
           continue;
         Value expectedSize = arith::ConstantIndexOp::create(
             builder, loc, resultType.getDimSize(i));
-        Value isEqual = arith::CmpIOp::create(
-            builder, loc, arith::CmpIPredicate::eq, shapeValues[i],
-            expectedSize);
+        Value isEqual =
+            arith::CmpIOp::create(builder, loc, arith::CmpIPredicate::eq,
+                                  shapeValues[i], expectedSize);
         cf::AssertOp::create(
             builder, loc, isEqual,
             generateErrorMessage(op, "shape operand value does not match "
@@ -444,23 +443,22 @@ struct ReshapeOpInterface
     std::optional<Value> shapeProduct;
     for (Value shapeValue : shapeValues) {
       shapeProduct =
-          shapeProduct ? arith::MulIOp::create(builder, loc, *shapeProduct,
-                                               shapeValue)
-                       : shapeValue;
+          shapeProduct
+              ? arith::MulIOp::create(builder, loc, *shapeProduct, shapeValue)
+              : shapeValue;
     }
     if (!shapeProduct)
       shapeProduct = arith::ConstantIndexOp::create(builder, loc, 1);
 
-    Value isEqual = arith::CmpIOp::create(
-        builder, loc, arith::CmpIPredicate::eq, *shapeProduct,
-        sourceNumElements);
+    Value isEqual =
+        arith::CmpIOp::create(builder, loc, arith::CmpIPredicate::eq,
+                              *shapeProduct, sourceNumElements);
     cf::AssertOp::create(
         builder, loc, isEqual,
         generateErrorMessage(op, "product of shape operand values does not "
                                  "equal number of elements in source"));
   }
 };
-
 } // namespace
 } // namespace tensor
 } // namespace mlir

``````````

</details>


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


More information about the Mlir-commits mailing list