[Mlir-commits] [mlir] d58f586 - [mlir][Affine] Use stable sorting to prevent non-determinism
Tres Popp
llvmlistbot at llvm.org
Wed Mar 15 09:18:44 PDT 2023
Author: Tres Popp
Date: 2023-03-15T17:18:33+01:00
New Revision: d58f5863c44d1a5b214f80d9b5c1123412c44ce2
URL: https://github.com/llvm/llvm-project/commit/d58f5863c44d1a5b214f80d9b5c1123412c44ce2
DIFF: https://github.com/llvm/llvm-project/commit/d58f5863c44d1a5b214f80d9b5c1123412c44ce2.diff
LOG: [mlir][Affine] Use stable sorting to prevent non-determinism
Differential Revision: https://reviews.llvm.org/D146151
Added:
Modified:
mlir/lib/Dialect/Affine/Transforms/DecomposeAffineOps.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Affine/Transforms/DecomposeAffineOps.cpp b/mlir/lib/Dialect/Affine/Transforms/DecomposeAffineOps.cpp
index aee32e37ba165..daa58b5d8986b 100644
--- a/mlir/lib/Dialect/Affine/Transforms/DecomposeAffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/DecomposeAffineOps.cpp
@@ -48,10 +48,9 @@ void mlir::reorderOperandsByHoistability(RewriterBase &rewriter,
int64_t numOperands = op.getNumOperands();
SmallVector<int64_t> operandPositions =
llvm::to_vector(llvm::seq<int64_t>(0, numOperands));
- std::sort(operandPositions.begin(), operandPositions.end(),
- [&numInvariant](size_t i1, size_t i2) {
- return numInvariant[i1] > numInvariant[i2];
- });
+ llvm::stable_sort(operandPositions, [&numInvariant](size_t i1, size_t i2) {
+ return numInvariant[i1] > numInvariant[i2];
+ });
SmallVector<AffineExpr> replacements(numOperands);
SmallVector<Value> operands(numOperands);
@@ -144,10 +143,9 @@ FailureOr<AffineApplyOp> mlir::decompose(RewriterBase &rewriter,
return i;
return -1;
};
- std::sort(subExpressions.begin(), subExpressions.end(),
- [&](AffineExpr e1, AffineExpr e2) {
- return getMaxSymbol(e1) < getMaxSymbol(e2);
- });
+ llvm::stable_sort(subExpressions, [&](AffineExpr e1, AffineExpr e2) {
+ return getMaxSymbol(e1) < getMaxSymbol(e2);
+ });
LLVM_DEBUG(
llvm::interleaveComma(subExpressions, DBGS() << "--sorted subexprs: ");
llvm::dbgs() << "\n");
More information about the Mlir-commits
mailing list