[Mlir-commits] [mlir] aff9c89 - [mlir][sparse] Simplifying closure
wren romano
llvmlistbot at llvm.org
Thu May 19 15:15:40 PDT 2022
Author: wren romano
Date: 2022-05-19T15:15:33-07:00
New Revision: aff9c89fabb3a50e6da31fb739b22ad2ed76bf62
URL: https://github.com/llvm/llvm-project/commit/aff9c89fabb3a50e6da31fb739b22ad2ed76bf62
DIFF: https://github.com/llvm/llvm-project/commit/aff9c89fabb3a50e6da31fb739b22ad2ed76bf62.diff
LOG: [mlir][sparse] Simplifying closure
By closing over the `rank` itself rather than `this`, we save a method call on each iteration. A minor optimization, but one that adds up.
Depends On D126016
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D126019
Added:
Modified:
mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
Removed:
################################################################################
diff --git a/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp b/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
index 11a40b7f4d88..53d26d5af689 100644
--- a/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
+++ b/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp
@@ -173,9 +173,9 @@ struct SparseTensorCOO final {
assert(!iteratorLocked && "Attempt to sort() after startIterator()");
// TODO: we may want to cache an `isSorted` bit, to avoid
// unnecessary/redundant sorting.
+ uint64_t rank = getRank();
std::sort(elements.begin(), elements.end(),
- [this](const Element<V> &e1, const Element<V> &e2) {
- uint64_t rank = getRank();
+ [rank](const Element<V> &e1, const Element<V> &e2) {
for (uint64_t r = 0; r < rank; r++) {
if (e1.indices[r] == e2.indices[r])
continue;
More information about the Mlir-commits
mailing list