Skip to content

[ARITH] Simplifier Improvement #2173

@sgrechanik-h

Description

@sgrechanik-h
  • The simplifier does not simplify (y - x) - y. Interestingly, (y - x) - y < 0 is simplified, but (y - x) - y > 0 is not:
    x = tvm.var('x')
    y = tvm.var('y')
    print(tvm.ir_pass.Simplify((y - x) - y))
    print(tvm.ir_pass.Simplify((y - x) - y > 0))
    print(tvm.ir_pass.Simplify((y - x) - y < 0))
    
    Output:
    ((y - x) - y)
    (0 < ((y - x) - y))
    (0 < x)
    
    CanonicalSimplify works well on this example though.
  • The simplifier rewrites (3*x + y)/3 into x + (y/3). Since tvm uses C/C++ truncated division instead of flooring or euclidean division, this is wrong (e.g. x = 1, y = -1). Recently there was a related issue here. However, instead of disabling another simplification rule I would suggest discussing another option: using Euclidean division in TVM, since the Euclidean definition has some advantages regarding program transformations, and it was originally used in Halide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions