Skip to content

[mlir] Use llvm::is_contained (NFC) #140012

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented May 15, 2025

@llvm/pr-subscribers-mlir-linalg
@llvm/pr-subscribers-mlir-quant

@llvm/pr-subscribers-mlir

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/140012.diff

3 Files Affected:

  • (modified) mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp (+2-2)
  • (modified) mlir/lib/Dialect/Mesh/IR/MeshOps.cpp (+1-1)
  • (modified) mlir/lib/Dialect/Quant/IR/QuantOps.cpp (+1-1)
diff --git a/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp b/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp
index 0cc840403a020..e8d460020cf69 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/TilingInterfaceImpl.cpp
@@ -511,7 +511,7 @@ struct LinalgOpPartialReductionInterface
       for (auto [resultNum, dimExpr] :
            llvm::enumerate(partialMap.getResults())) {
         unsigned dim = cast<AffineDimExpr>(dimExpr).getPosition();
-        if (llvm::find(reductionDims, dim) != reductionDims.end()) {
+        if (llvm::is_contained(reductionDims, dim)) {
           partialReductionDims.push_back(resultNum);
         }
       }
@@ -553,7 +553,7 @@ struct LinalgOpPartialReductionInterface
       unsigned dim = cast<AffineDimExpr>(dimExpr).getPosition();
       resultSizes.push_back(sizes[dim]);
 
-      if (llvm::find(reductionDims, dim) != reductionDims.end()) {
+      if (llvm::is_contained(reductionDims, dim)) {
         // Reduction dims are reduced, and are always outputed in the same
         // place. So use offset 0 for them.
         resultOffsets.push_back(b.getIndexAttr(0));
diff --git a/mlir/lib/Dialect/Mesh/IR/MeshOps.cpp b/mlir/lib/Dialect/Mesh/IR/MeshOps.cpp
index 1a1334f0ea474..2bdb58892937f 100644
--- a/mlir/lib/Dialect/Mesh/IR/MeshOps.cpp
+++ b/mlir/lib/Dialect/Mesh/IR/MeshOps.cpp
@@ -1505,7 +1505,7 @@ LogicalResult ShiftOp::verifySymbolUses(SymbolTableCollection &symbolTable) {
 
   auto meshAxes = getMeshAxes();
   auto shiftAxis = getShiftAxis().getZExtValue();
-  if (llvm::find(meshAxes, shiftAxis) == meshAxes.end()) {
+  if (!llvm::is_contained(meshAxes, shiftAxis)) {
     return emitError() << "Invalid shift axis " << shiftAxis
                        << ". It must be one of the grouping mesh axes.";
   }
diff --git a/mlir/lib/Dialect/Quant/IR/QuantOps.cpp b/mlir/lib/Dialect/Quant/IR/QuantOps.cpp
index 94e1c8b8ba296..e23a0d6aba825 100644
--- a/mlir/lib/Dialect/Quant/IR/QuantOps.cpp
+++ b/mlir/lib/Dialect/Quant/IR/QuantOps.cpp
@@ -122,7 +122,7 @@ LogicalResult verifySubChannelQuantization(
   //
   // Therefore, we explicitly disallow the case where d = 0 to maintain
   // consistency and avoid these issues.
-  if (llvm::find(tensorType.getShape(), 0) != tensorType.getShape().end()) {
+  if (llvm::is_contained(tensorType.getShape(), 0)) {
     return op->emitError() << "tensor dimension size of zero is not allowed "
                               "with sub-channel quantization";
   }

@kazutakahirata kazutakahirata merged commit d9ab5bc into llvm:main May 15, 2025
15 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_range_llvm_is_contained_mlir branch May 15, 2025 14:18
TIFitis pushed a commit to TIFitis/llvm-project that referenced this pull request May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants