-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
[Bugfix] [tir] do not simplify 'Any() - Any()' to 0 #8266
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Also cc @icemelon9 @junrushao1994 @Hzfengsy
Does it actually make sense to support this rule? semantically I'm not sure we guarantee that the same Any variable is equivalent. For example:
Conceptually I'm not sure: t1.shape == t2.shape at runtime. |
@@ -293,6 +294,9 @@ def test_sub_index_simplify(): | |||
|
|||
# mul co-efficient foldng | |||
ck.verify(x - x, 0) | |||
ck.verify(a - a, 0) | |||
ck.verify(a - b, a - b) | |||
ck.verify(a - b, c - c) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why could we verify a-b == c-c == 0
? This doesn't make sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this line, a - b
will not be simplified, it is still a - b
, so structural_equal((a - b), (c-c))
is True (rhs will not be simplified in ck.verify
). Just test the functionality of structural_equal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not simplifying a - b
is correct, but I think a - b
is not structural equal to c - c
as a
and b
refer to two different variable but c - c
are the same variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line now. Semantically, a - b
is not equal to c - c
, but structural_equal((a - b), (c-c))
works because for AnyNode it use the SEqualReduce
function which only checks the node's dtype. In fact, a function contains AnyNode(s) in its ret_type
after InferType will have new AnyNode(s), the two func then differs though they pass the tests.
I think a long term approach should be map Any
like Var
when checking the structures. So just keep it for now?
Do you mean IMHO, since the shapes share the same |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@jroesch PTAL.
Thanks @hgt312 @icemelon9 @comaniac @MarisaKirisame! It is now merged |
* fix * fix lint * remove * address comments
* fix * fix lint * remove * address comments
To reproduce
With this change,
tir
considersa
andb
as different. However,structural_equal
still consider them as the same.@yzhliu @comaniac