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: 3 additions & 0 deletions src/arithmetic/canonical.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ class Canonical::Internal : public IRMutator {
ret_entry_.max_level = stack_.back().max_level;
stack_.pop_back();
CHECK(expr.defined());
if (const IntImm* op = expr.as<IntImm>()) {
return Mutate_(op, expr);
}
return expr;
}
// call produce to get a cache entry.
Expand Down
10 changes: 10 additions & 0 deletions tests/python/unittest/test_pass_simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ def test_basic():
assert str(ret.value) == "(m - 1)"


def test_canonical():
x = tvm.var("x")
z = tvm.const(3)
ret = tvm.ir_pass.CanonicalSimplify(x / (z*z) - x / (z*z))
assert(tvm.ir_pass.Equal(ret, 0))

ret = tvm.ir_pass.CanonicalSimplify(x / (z+z) - x / (z+z))
assert(tvm.ir_pass.Equal(ret, 0))

if __name__ == "__main__":
test_basic()
test_simplify()
test_canonical()