Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/arithmetic/detect_linear_equation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ class LinearEqDetector
return ComputeExpr<Add>(a, b);
}
Expr SubCombine(Expr a, Expr b) {
if (!a.defined()) return -b;
// Check b first in case they are both undefined
if (!b.defined()) return a;
if (!a.defined()) return -b;
return ComputeExpr<Sub>(a, b);
}
Expr MulCombine(Expr a, Expr b) {
Expand Down
4 changes: 4 additions & 0 deletions tests/python/unittest/test_arith_detect_linear_equation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ def test_multivariate():
assert(m[2].value == 2)
assert(m[len(m)-1].value == 2)

m = tvm.arith.DetectLinearEquation((v[0] - v[1]), [v[2]])
assert(m[0].value == 0)
assert(tvm.ir_pass.Simplify(m[1] - (v[0] - v[1])).value == 0)

if __name__ == "__main__":
test_basic()
test_multivariate()