[mlir][Arith] ValueBoundsInterface: speedup arith.select (#113531)
When calculating value bounds in the arith.select op , the compare function is invoked to compare trueValue and falseValue. This function rebuilds constraints, resulting in repeated computations of value bounds. In large-scale programs, this redundancy significantly impacts compilation time.
This commit is contained in:
@@ -107,9 +107,10 @@ struct SelectOpInterface
|
||||
// If trueValue <= falseValue:
|
||||
// * result <= falseValue
|
||||
// * result >= trueValue
|
||||
if (cstr.compare(/*lhs=*/{trueValue, dim},
|
||||
ValueBoundsConstraintSet::ComparisonOperator::LE,
|
||||
/*rhs=*/{falseValue, dim})) {
|
||||
if (cstr.populateAndCompare(
|
||||
/*lhs=*/{trueValue, dim},
|
||||
ValueBoundsConstraintSet::ComparisonOperator::LE,
|
||||
/*rhs=*/{falseValue, dim})) {
|
||||
if (dim) {
|
||||
cstr.bound(value)[*dim] >= cstr.getExpr(trueValue, dim);
|
||||
cstr.bound(value)[*dim] <= cstr.getExpr(falseValue, dim);
|
||||
@@ -121,9 +122,10 @@ struct SelectOpInterface
|
||||
// If falseValue <= trueValue:
|
||||
// * result <= trueValue
|
||||
// * result >= falseValue
|
||||
if (cstr.compare(/*lhs=*/{falseValue, dim},
|
||||
ValueBoundsConstraintSet::ComparisonOperator::LE,
|
||||
/*rhs=*/{trueValue, dim})) {
|
||||
if (cstr.populateAndCompare(
|
||||
/*lhs=*/{falseValue, dim},
|
||||
ValueBoundsConstraintSet::ComparisonOperator::LE,
|
||||
/*rhs=*/{trueValue, dim})) {
|
||||
if (dim) {
|
||||
cstr.bound(value)[*dim] >= cstr.getExpr(falseValue, dim);
|
||||
cstr.bound(value)[*dim] <= cstr.getExpr(trueValue, dim);
|
||||
|
||||
Reference in New Issue
Block a user