diff --git a/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp b/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp --- a/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp +++ b/mlir/lib/ExecutionEngine/SparseTensorUtils.cpp @@ -173,9 +173,9 @@ 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 &e1, const Element &e2) { - uint64_t rank = getRank(); + [rank](const Element &e1, const Element &e2) { for (uint64_t r = 0; r < rank; r++) { if (e1.indices[r] == e2.indices[r]) continue;