-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 Check about negative uint constant #10484
Conversation
Could any reviewer help take a look about why my commit fails in sanity check? I do not have adequate experience in commiting fixes. Thanks in advance. cc @junrushao1994 @jroesch |
@haoyang9804 You can find the Sanity Check Log here. change [2022-03-04T06:18:11.419Z] - ICHECK(!(pa && pa->dtype.is_uint() && pa->value == 0U && b.dtype().is_uint())) << \
[2022-03-04T06:18:11.419Z] - "Checked failed. Minuend 's value is 0U and it's dtype is uint " << \
[2022-03-04T06:18:11.419Z] - "while Subtrahend's dtype is uint; which will cause a negative unit"; to [2022-03-04T06:18:11.419Z] + ICHECK(!(pa && pa->dtype.is_uint() && pa->value == 0U && b.dtype().is_uint()))
[2022-03-04T06:18:11.419Z] + << "Checked failed. Minuend 's value is 0U and it's dtype is uint "
[2022-03-04T06:18:11.419Z] + << "while Subtrahend's dtype is uint; which will cause a negative uint"; You'd better run the check locally before sending a PR. bash ./tests/scripts/task_lint.sh |
|
@leeexyz Thanks for you kind reply. Though I cannot run this lint script locally due to inaccessibility of some files. But finally it works after I change the format of the code. |
Hi @masahi. Would you mind to take a look at this pr. Maybe it's a small problem, but I think it shows an inconsistency between uint const and uint var. |
A check for unsigned integer overflow would throw an error if it encountered 0U - 0U. apache#10484, which introduced the check, and apache#9727, which introduced this edge case, were in CI at the same time, and each was tested against a merge candidate that did not include the other. The unittest failure only occurred when both PRs were merged.
A check for unsigned integer overflow would throw an error if it encountered 0U - 0U. apache#10484, which introduced the check, and apache#9727, which introduced this edge case, were in CI at the same time, and each was tested against a merge candidate that did not include the other. The unittest failure only occurred when both PRs were merged.
A check for unsigned integer overflow would throw an error if it encountered 0U - 0U. #10484, which introduced the check, and #9727, which introduced this edge case, were in CI at the same time, and each was tested against a merge candidate that did not include the other. The unittest failure only occurred when both PRs were merged.
* fix InferType bug * fix InferType related bug * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative
A check for unsigned integer overflow would throw an error if it encountered 0U - 0U. apache#10484, which introduced the check, and apache#9727, which introduced this edge case, were in CI at the same time, and each was tested against a merge candidate that did not include the other. The unittest failure only occurred when both PRs were merged.
* fix InferType bug * fix InferType related bug * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative * check if uint variable is negative
A check for unsigned integer overflow would throw an error if it encountered 0U - 0U. apache#10484, which introduced the check, and apache#9727, which introduced this edge case, were in CI at the same time, and each was tested against a merge candidate that did not include the other. The unittest failure only occurred when both PRs were merged.
Focusing the problem in here.
As the author said, when we
negative
afterones_like
auint
variable, tvm crashes as expected. Butnegative
a uint const would run smoothly. So I tried the following script, only changingrelay.var
torelay.const
, which should crash but not.I have make the following change to the codebase:
In
TryConstFold<tir::Sub>
, which is needed fornegative
operator, I add a check about potential negative uint value: If minuend is of uint and it's value is 0 while the subtrahend is of uint, then the difference would be negative and of uint. This situation should be forbidden.