[mlir][sparse] using stable_sort to make sure the compiled code are consistent betwee...
authorPeiming Liu <peiming@google.com>
Thu, 15 Jun 2023 21:04:46 +0000 (21:04 +0000)
committerPeiming Liu <peiming@google.com>
Thu, 15 Jun 2023 21:09:35 +0000 (21:09 +0000)
Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D153074

mlir/lib/Dialect/SparseTensor/Transforms/LoopEmitter.cpp

index e3abe10..9a130ec 100644 (file)
@@ -528,7 +528,7 @@ void LoopEmitter::categorizeLoopCondition(
         makeLoopCondKind(isSparse, isSlice, isAffine, isUnRedu));
   }
 
-  std::sort(spConds.begin(), spConds.end(), [](auto lhs, auto rhs) {
+  std::stable_sort(spConds.begin(), spConds.end(), [](auto lhs, auto rhs) {
     // AffineUnRed > Affine > Slice > Trivial
     return static_cast<uint8_t>(lhs.second) > static_cast<uint8_t>(rhs.second);
   });