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

[ARITH] Add support for EQ op in the deduce bound and the loop partition #3775

Merged
merged 1 commit into from
Sep 13, 2019

Conversation

umangyadav
Copy link
Contributor

@umangyadav umangyadav commented Aug 14, 2019

Solves #3774

Adds support for EQ op in the deduce bound.

The main check required for EQ is that both LHS and RHS should be constant at the time of relaxing them. e.g. for (i==j) then, both EvalSet over
i and j both should be a single point. In other words, EQ condition can not be resolved if one of the operands is variable.

Secondly, for EQ with multiplication where there is no perfect division, e.g (4 * i == 10) can not be solved because division truncation will change one of the operands.

This PR extends DeduceBound for EQ and adds unittests for the same.

LoopPartition uses the deduce_bound and with EQ support, LoopPartition is also changed to partition based on EQ conditions. Unittest for the same is added.

@umangyadav
Copy link
Contributor Author

@ZihengJiang @tqchen @derisavi @xqdan can you please review this? thanks.

assert str(res9.min_value) == "pos_inf"

# Unsatisfiable Mul in `EQ`
res10 = tvm.arith.DeduceBound(a, (b * a == b), {b: b_s}, {}) # simplifier is not able to prove that (b % b == 0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tqchen @xqdan I noticed that TVM wasn't able to prove that b % b == 0 where b is a variable. Is it something expected ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this can be improved @tqchen

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be improved by adding a rewrite pattern

@umangyadav umangyadav changed the title Add support for EQ op in the deduce bound and the loop partition [ARITH] Add support for EQ op in the deduce bound and the loop partition Aug 14, 2019
Copy link
Member

@yzhliu yzhliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall it looks good to me.

src/arithmetic/bound_deducer.cc Outdated Show resolved Hide resolved
case kGreater: return kLess;
case kLess: return kGreater;
default:
return kGreater;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOG(FATAL) instead?

Copy link
Contributor Author

@umangyadav umangyadav Sep 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yzhliu @tqchen Added the LOG(FATAL)

assert str(res9.min_value) == "pos_inf"

# Unsatisfiable Mul in `EQ`
res10 = tvm.arith.DeduceBound(a, (b * a == b), {b: b_s}, {}) # simplifier is not able to prove that (b % b == 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this can be improved @tqchen

@yzhliu
Copy link
Member

yzhliu commented Sep 5, 2019

ping @umangyadav @tqchen

2) Add EQ support in the loop partition and add test for the same
3) Change typo truc to trunc
@umangyadav
Copy link
Contributor Author

ping @yzhliu @tqchen

@tqchen tqchen merged commit 4b431c6 into apache:master Sep 13, 2019
@tqchen
Copy link
Member

tqchen commented Sep 13, 2019

Thanks @umangyadav @yzhliu @u99127

wweic pushed a commit to wweic/tvm that referenced this pull request Sep 16, 2019
…he#3775)

2) Add EQ support in the loop partition and add test for the same
3) Change typo truc to trunc
wweic pushed a commit to wweic/tvm that referenced this pull request Sep 16, 2019
…he#3775)

2) Add EQ support in the loop partition and add test for the same
3) Change typo truc to trunc
wweic pushed a commit to neo-ai/tvm that referenced this pull request Sep 16, 2019
…he#3775)

2) Add EQ support in the loop partition and add test for the same
3) Change typo truc to trunc
@umangyadav umangyadav deleted the deduce_bound_EQ branch September 30, 2019 18:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants