[Mlir-commits] [mlir] [mlir] Use llvm::is_contained (NFC) (PR #102714)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Aug 9 19:59:21 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-linalg

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>



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


5 Files Affected:

- (modified) mlir/lib/Analysis/Presburger/Barvinok.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp (+1-2) 
- (modified) mlir/lib/Dialect/Linalg/Transforms/Specialize.cpp (+1-3) 
- (modified) mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp (+1-2) 
- (modified) mlir/lib/Dialect/MemRef/Transforms/EmulateNarrowType.cpp (+2-4) 


``````````diff
diff --git a/mlir/lib/Analysis/Presburger/Barvinok.cpp b/mlir/lib/Analysis/Presburger/Barvinok.cpp
index fad4364391d569..0e82f973b49b94 100644
--- a/mlir/lib/Analysis/Presburger/Barvinok.cpp
+++ b/mlir/lib/Analysis/Presburger/Barvinok.cpp
@@ -357,7 +357,7 @@ mlir::presburger::detail::computePolytopeGeneratingFunction(
 
     if (!vertex)
       continue;
-    if (std::find(vertices.begin(), vertices.end(), vertex) != vertices.end())
+    if (llvm::is_contained(vertices, vertex))
       continue;
     // If this subset corresponds to a vertex that has not been considered,
     // store it.
diff --git a/mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp b/mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp
index 0741e147cdd69e..d79399b6588be3 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp
@@ -725,8 +725,7 @@ projectDimsPosIntoReassocPos(ArrayRef<int64_t> dimsPos,
       // If the dimension is present in the current indices group, the group
       // position within the reassociation map is the desired projected
       // dimension position.
-      if (llvm::any_of(indices,
-                       [&](int64_t expandDim) { return expandDim == pos; })) {
+      if (llvm::is_contained(indices, pos)) {
         projectedPos.push_back(idx);
         break;
       }
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Specialize.cpp b/mlir/lib/Dialect/Linalg/Transforms/Specialize.cpp
index 78bfa383d25a2a..4d7b748d7200e2 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Specialize.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Specialize.cpp
@@ -227,9 +227,7 @@ static FailureOr<LinalgOp> specializeLinalgContractions(RewriterBase &rewriter,
   auto c =
       matchOperandMap(indexingMaps[2], numOfBatchDims, dims.m[0], dims.n[0]);
 
-  if (llvm::any_of(ArrayRef<IndexMatchResult>{a, b, c}, [](IndexMatchResult r) {
-        return r == IndexMatchResult::Mismatch;
-      }))
+  if (llvm::is_contained({a, b, c}, IndexMatchResult::Mismatch))
     return failure();
 
   if (c != IndexMatchResult::Match ||
diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
index 779ffbfc23f4d7..0ff25de7295f6e 100644
--- a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
+++ b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
@@ -838,8 +838,7 @@ struct FoldEmptyCopy final : public OpRewritePattern<CopyOp> {
   using OpRewritePattern<CopyOp>::OpRewritePattern;
 
   static bool isEmptyMemRef(BaseMemRefType type) {
-    return type.hasRank() &&
-           llvm::any_of(type.getShape(), [](int64_t x) { return x == 0; });
+    return type.hasRank() && llvm::is_contained(type.getShape(), 0);
   }
 
   LogicalResult matchAndRewrite(CopyOp copyOp,
diff --git a/mlir/lib/Dialect/MemRef/Transforms/EmulateNarrowType.cpp b/mlir/lib/Dialect/MemRef/Transforms/EmulateNarrowType.cpp
index 20ce1b1da4c9bf..88d56a8fbec749 100644
--- a/mlir/lib/Dialect/MemRef/Transforms/EmulateNarrowType.cpp
+++ b/mlir/lib/Dialect/MemRef/Transforms/EmulateNarrowType.cpp
@@ -58,8 +58,7 @@ convertCastingOp(ConversionPatternRewriter &rewriter,
   auto sizes = op.getStaticSizes();
   int64_t offset = op.getStaticOffset(0);
   // Only support static sizes and offsets.
-  if (llvm::any_of(sizes,
-                   [](int64_t size) { return size == ShapedType::kDynamic; }) ||
+  if (llvm::is_contained(sizes, ShapedType::kDynamic) ||
       offset == ShapedType::kDynamic) {
     return rewriter.notifyMatchFailure(
         op, "dynamic size or offset is not supported");
@@ -436,8 +435,7 @@ struct ConvertMemRefSubview final : OpConversionPattern<memref::SubViewOp> {
     auto sizes = subViewOp.getStaticSizes();
     int64_t lastOffset = subViewOp.getStaticOffsets().back();
     // Only support static sizes and offsets.
-    if (llvm::any_of(
-            sizes, [](int64_t size) { return size == ShapedType::kDynamic; }) ||
+    if (llvm::is_contained(sizes, ShapedType::kDynamic) ||
         lastOffset == ShapedType::kDynamic) {
       return rewriter.notifyMatchFailure(
           subViewOp->getLoc(), "dynamic size or offset is not supported");

``````````

</details>


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


More information about the Mlir-commits mailing list