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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Aug 9 21:42:22 PDT 2024


Author: Kazu Hirata
Date: 2024-08-09T21:42:19-07:00
New Revision: 165f45354ae51bd00fe9000afbdcc4405e360b02

URL: https://github.com/llvm/llvm-project/commit/165f45354ae51bd00fe9000afbdcc4405e360b02
DIFF: https://github.com/llvm/llvm-project/commit/165f45354ae51bd00fe9000afbdcc4405e360b02.diff

LOG: [mlir] Use llvm::is_contained (NFC) (#102714)

Added: 
    

Modified: 
    mlir/lib/Analysis/Presburger/Barvinok.cpp
    mlir/lib/Dialect/Linalg/Transforms/DataLayoutPropagation.cpp
    mlir/lib/Dialect/Linalg/Transforms/Specialize.cpp
    mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
    mlir/lib/Dialect/MemRef/Transforms/EmulateNarrowType.cpp

Removed: 
    


################################################################################
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");


        


More information about the Mlir-commits mailing list