[Mlir-commits] [mlir] [mlir] Use llvm::unique (NFC) (PR #96415)

Kazu Hirata llvmlistbot at llvm.org
Sat Jun 22 21:26:30 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/96415

None

>From b475595b9a43f4fa3e7247f3ee457b72fbadb192 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 22 Jun 2024 21:09:33 -0700
Subject: [PATCH] [mlir] Use llvm::unique (NFC)

---
 mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp         | 4 +---
 mlir/lib/Dialect/GPU/Transforms/NVVMAttachTarget.cpp      | 3 +--
 mlir/lib/Dialect/GPU/Transforms/ROCDLAttachTarget.cpp     | 3 +--
 mlir/lib/Dialect/GPU/Transforms/SPIRVAttachTarget.cpp     | 2 +-
 mlir/lib/Dialect/Transform/Interfaces/MatchInterfaces.cpp | 2 +-
 mlir/lib/IR/AffineMap.cpp                                 | 3 +--
 mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp        | 3 +--
 7 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
index bb319208f58a8..5891e2fa0067e 100644
--- a/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/LoopFusion.cpp
@@ -162,9 +162,7 @@ static void getProducerCandidates(unsigned dstId, MemRefDependenceGraph *mdg,
   }
 
   llvm::sort(srcIdCandidates);
-  srcIdCandidates.erase(
-      std::unique(srcIdCandidates.begin(), srcIdCandidates.end()),
-      srcIdCandidates.end());
+  srcIdCandidates.erase(llvm::unique(srcIdCandidates), srcIdCandidates.end());
 }
 
 /// Returns in 'producerConsumerMemrefs' the memrefs involved in a
diff --git a/mlir/lib/Dialect/GPU/Transforms/NVVMAttachTarget.cpp b/mlir/lib/Dialect/GPU/Transforms/NVVMAttachTarget.cpp
index e4efcacaa7524..ad6b0afa29a1a 100644
--- a/mlir/lib/Dialect/GPU/Transforms/NVVMAttachTarget.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/NVVMAttachTarget.cpp
@@ -78,8 +78,7 @@ void NVVMAttachTarget::runOnOperation() {
           targets.append(attrs->getValue().begin(), attrs->getValue().end());
         targets.push_back(target);
         // Remove any duplicate targets.
-        targets.erase(std::unique(targets.begin(), targets.end()),
-                      targets.end());
+        targets.erase(llvm::unique(targets), targets.end());
         // Update the target attribute array.
         module.setTargetsAttr(builder.getArrayAttr(targets));
       }
diff --git a/mlir/lib/Dialect/GPU/Transforms/ROCDLAttachTarget.cpp b/mlir/lib/Dialect/GPU/Transforms/ROCDLAttachTarget.cpp
index 925f4a9c1085d..60f6a74748828 100644
--- a/mlir/lib/Dialect/GPU/Transforms/ROCDLAttachTarget.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/ROCDLAttachTarget.cpp
@@ -86,8 +86,7 @@ void ROCDLAttachTarget::runOnOperation() {
           targets.append(attrs->getValue().begin(), attrs->getValue().end());
         targets.push_back(target);
         // Remove any duplicate targets.
-        targets.erase(std::unique(targets.begin(), targets.end()),
-                      targets.end());
+        targets.erase(llvm::unique(targets), targets.end());
         // Update the target attribute array.
         module.setTargetsAttr(builder.getArrayAttr(targets));
       }
diff --git a/mlir/lib/Dialect/GPU/Transforms/SPIRVAttachTarget.cpp b/mlir/lib/Dialect/GPU/Transforms/SPIRVAttachTarget.cpp
index 88c365d9ce3eb..e4468ed6d2884 100644
--- a/mlir/lib/Dialect/GPU/Transforms/SPIRVAttachTarget.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/SPIRVAttachTarget.cpp
@@ -91,7 +91,7 @@ void SPIRVAttachTarget::runOnOperation() {
       targets.append(attrs->getValue().begin(), attrs->getValue().end());
     targets.push_back(target);
     // Remove any duplicate targets.
-    targets.erase(std::unique(targets.begin(), targets.end()), targets.end());
+    targets.erase(llvm::unique(targets), targets.end());
     // Update the target attribute array.
     gpuModule.setTargetsAttr(builder.getArrayAttr(targets));
   });
diff --git a/mlir/lib/Dialect/Transform/Interfaces/MatchInterfaces.cpp b/mlir/lib/Dialect/Transform/Interfaces/MatchInterfaces.cpp
index 4151d0ea5bee0..783eb137b9aff 100644
--- a/mlir/lib/Dialect/Transform/Interfaces/MatchInterfaces.cpp
+++ b/mlir/lib/Dialect/Transform/Interfaces/MatchInterfaces.cpp
@@ -93,7 +93,7 @@ LogicalResult transform::verifyTransformMatchDimsOp(Operation *op,
                                 "'all' is not specified";
   }
   SmallVector<int64_t> rawVector = llvm::to_vector(raw);
-  auto *it = std::unique(rawVector.begin(), rawVector.end());
+  auto *it = llvm::unique(rawVector);
   if (it != rawVector.end())
     return op->emitOpError() << "expected the listed values to be unique";
 
diff --git a/mlir/lib/IR/AffineMap.cpp b/mlir/lib/IR/AffineMap.cpp
index ce7b751294cc9..e5993eb08dc8b 100644
--- a/mlir/lib/IR/AffineMap.cpp
+++ b/mlir/lib/IR/AffineMap.cpp
@@ -748,8 +748,7 @@ AffineMap mlir::simplifyAffineMap(AffineMap map) {
 AffineMap mlir::removeDuplicateExprs(AffineMap map) {
   auto results = map.getResults();
   SmallVector<AffineExpr, 4> uniqueExprs(results.begin(), results.end());
-  uniqueExprs.erase(std::unique(uniqueExprs.begin(), uniqueExprs.end()),
-                    uniqueExprs.end());
+  uniqueExprs.erase(llvm::unique(uniqueExprs), uniqueExprs.end());
   return AffineMap::get(map.getNumDims(), map.getNumSymbols(), uniqueExprs,
                         map.getContext());
 }
diff --git a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
index ae0961c62abad..76b066feb6930 100644
--- a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
+++ b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
@@ -1808,8 +1808,7 @@ void lsp::PDLLServer::getInlayHints(const URIForFile &uri, const Range &range,
 
   // Drop any duplicated hints that may have cropped up.
   llvm::sort(inlayHints);
-  inlayHints.erase(std::unique(inlayHints.begin(), inlayHints.end()),
-                   inlayHints.end());
+  inlayHints.erase(llvm::unique(inlayHints), inlayHints.end());
 }
 
 std::optional<lsp::PDLLViewOutputResult>



More information about the Mlir-commits mailing list