[Mlir-commits] [mlir] [mlir][Utils] Add VerificationUtils for common op verification patterns (NFC) (PR #174336)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Jan 4 08:27:08 PST 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,h -- mlir/include/mlir/Dialect/Utils/VerificationUtils.h mlir/lib/Dialect/Utils/VerificationUtils.cpp mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp mlir/lib/Dialect/Tensor/IR/TensorOps.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/Bufferization/IR/BufferizationOps.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
index 5df97324c..eda6bf276 100644
--- a/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
+++ b/mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp
@@ -252,9 +252,8 @@ AllocTensorOp::getBufferType(Value value, const BufferizationOptions &options,
 LogicalResult AllocTensorOp::verify() {
   if (getCopy() && !getDynamicSizes().empty())
     return emitError("dynamic sizes not needed when copying a tensor");
-  if (!getCopy() &&
-      failed(verifyDynamicDimensionCount(getOperation(), getType(),
-                                         getDynamicSizes())))
+  if (!getCopy() && failed(verifyDynamicDimensionCount(
+                        getOperation(), getType(), getDynamicSizes())))
     return failure();
   if (getCopy() && getCopy().getType() != getType())
     return emitError("expected that `copy` and return type match");
diff --git a/mlir/lib/Dialect/Utils/VerificationUtils.cpp b/mlir/lib/Dialect/Utils/VerificationUtils.cpp
index 25b84a679..60a591b9f 100644
--- a/mlir/lib/Dialect/Utils/VerificationUtils.cpp
+++ b/mlir/lib/Dialect/Utils/VerificationUtils.cpp
@@ -53,9 +53,8 @@ LogicalResult mlir::verifyRankEquals(Operation *op, ShapedType type,
 
   int64_t actualRank = type.getRank();
   if (actualRank != expectedRank) {
-    return op->emitOpError()
-           << typeName << " must have rank " << expectedRank << ", but has "
-           << actualRank;
+    return op->emitOpError() << typeName << " must have rank " << expectedRank
+                             << ", but has " << actualRank;
   }
   return success();
 }
@@ -95,9 +94,8 @@ LogicalResult mlir::verifyDimensionIndicesInRange(Operation *op,
                                                   StringRef context) {
   for (int64_t index : indices) {
     if (index < 0 || index >= maxDim) {
-      return op->emitOpError()
-             << context << " must be in the range [0, " << (maxDim - 1)
-             << "], but got " << index;
+      return op->emitOpError() << context << " must be in the range [0, "
+                               << (maxDim - 1) << "], but got " << index;
     }
   }
   return success();
@@ -195,8 +193,8 @@ LogicalResult mlir::verifyAllElementTypesMatch(Operation *op, ValueRange values,
       return op->emitOpError()
              << context << " must all have the same element type, but "
              << context << "[0] has element type " << firstElementType
-             << " while " << context << "[" << (idx + 1) << "] has element type "
-             << type.getElementType();
+             << " while " << context << "[" << (idx + 1)
+             << "] has element type " << type.getElementType();
     }
   }
   return success();
@@ -227,9 +225,8 @@ LogicalResult mlir::verifyElementCountsMatch(Operation *op, ShapedType type1,
   int64_t count1 = type1.getNumElements();
   int64_t count2 = type2.getNumElements();
   if (count1 != count2) {
-    return op->emitOpError()
-           << name1 << " has " << count1 << " elements, but " << name2
-           << " has " << count2 << " elements";
+    return op->emitOpError() << name1 << " has " << count1 << " elements, but "
+                             << name2 << " has " << count2 << " elements";
   }
   return success();
 }

``````````

</details>


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


More information about the Mlir-commits mailing list