Uh oh!
There was an error while loading. Please reload this page.
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 |
leeexyz
commented
Mar 4, 2022
@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 |
haoyang9804
commented
Mar 4, 2022
haoyang9804
commented
Mar 4, 2022
@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. |
haoyang9804
commented
Mar 8, 2022
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
negativeafterones_likeauintvariable, tvm crashes as expected. Butnegativea uint const would run smoothly. So I tried the following script, only changingrelay.vartorelay.const, which should crash but not.I have make the following change to the codebase:
In
TryConstFold<tir::Sub>, which is needed fornegativeoperator, 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.