Skip to content

Commit

Permalink
Add Check about negative uint constant (#10484)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
haoyang9804 authored Mar 8, 2022
1 parent 704ac8b commit f4b74ba
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/arith/const_fold.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ inline PrimExpr TryConstFold<tir::Add>(PrimExpr a, PrimExpr b) {
template <>
inline PrimExpr TryConstFold<tir::Sub>(PrimExpr a, PrimExpr b) {
TVM_ARITH_CONST_PROPAGATION({
ICHECK(!(pa && pa->dtype.is_uint() && pa->value == 0U && b.dtype().is_uint()))
<< "Checked failed. Minuend 's value is 0U and it's dtype is uint "
<< "while Subtrahend's dtype is uint; which will cause a negative uint";
const DataType& rtype = a.dtype();
if (pa && pb) return IntImm(rtype, pa->value - pb->value);
if (pb && pb->value == 0) return a;
Expand Down

0 comments on commit f4b74ba

Please sign in to comment.