[Mlir-commits] [mlir] [mlir] Avoid repeated map lookups (NFC) (PR #113074)

Kazu Hirata llvmlistbot at llvm.org
Sat Oct 19 21:01:44 PDT 2024


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

None

>From 516b43a1221b7b712dfbd91e79f2d1ce470e9315 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 19 Oct 2024 15:20:58 -0700
Subject: [PATCH] [mlir] Avoid repeated map lookups (NFC)

---
 mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
index 7b1b1f383e6343..c6e66ddbc7af9a 100644
--- a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
+++ b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
@@ -1160,9 +1160,8 @@ bool mlir::sparse_tensor::isBlockSparsity(AffineMap dimToLvl) {
     } else if (auto dimOp = dyn_cast<AffineDimExpr>(result)) {
       auto pos = dimOp.getPosition();
       // Expect dim to be unset.
-      if (coeffientMap.find(pos) != coeffientMap.end())
+      if (!coeffientMap.try_emplace(pos).second)
         return false;
-      coeffientMap[pos] = 0;
     } else {
       return false;
     }



More information about the Mlir-commits mailing list