Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality for removing zero extent loops in the RemovNoOp pass #3726

Closed
umangyadav opened this issue Aug 7, 2019 · 0 comments
Closed

Comments

@umangyadav
Copy link
Contributor

Consider the following example:

def test_generate_zero_extent_loop():
    ib = tvm.ir_builder.create()
    m = tvm.var('m')
    n = tvm.var('n')
    with ib.for_range(0, 16, "i") as i:
        with ib.if_scope(ib.likely(i>0)):
            with ib.if_scope(ib.likely(i<7)):
                ib.emit(tvm.make.Evaluate(m))

    stmt = ib.get()
    print("==================================")
    print(stmt)
    stmt = tvm.ir_pass.LoopPartition(stmt, True)
    print("==================================")
    print(stmt)
    stmt = tvm.ir_pass.Simplify(stmt)
    print("==================================")
    print(stmt)

In this case, LoopPartition gives the following output after the Simplify pass:

0
for (i, 0, 6) {
  m
}
for (i, 0, 0) {
  m
}
for (i, 0, 9) {
  0
}

Dead zero extent loops can be removed from RemoveNoOp pass if functionality for that is added.

@umangyadav umangyadav changed the title LoopPartition generates zero extent loops in certain cases Add functionality for removing zero extent loops in the RemovNoOp pass Aug 7, 2019
@tqchen tqchen closed this as completed Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants