[Mlir-commits] [mlir] [MLIR] Add replace-operands option to mlir-reduce (PR #153100)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Aug 16 15:49:12 PDT 2025
aidint wrote:
@jpienaar
> So this option would result in replacing all operands of an op with same type with another value?
Yes. Also, while having no effect, the value will also replace itself if it is used as an operand.
> Would it always be same one?
Good question. I guess so. The reduction tree algorithm itself appears to be deterministic. It constructs the same reduction nodes each time it processes a given test case.
The replace-operands functionality also operates deterministically at each reduction step. It creates a `DenseMap<Type, SmallVector<Value>>` at each step, inserting all the values into it while iterating over operations. The decision for replacement is based on dominance, so if there is a candidate value in the map that dominates the current operation, then the operand is replaced.
So as long as my assumption about the reduction tree algorithm is correct and there is no random traversal in the tree or no random generation in reduction nodes, then I believe with this addition we also get the same result every time.
https://github.com/llvm/llvm-project/pull/153100
More information about the Mlir-commits
mailing list