LiRunGuo opened a new pull request, #20414:
URL: https://github.com/apache/tvm/pull/20414

   When interval-set analysis combines a bounded interval with a single point 
of unknown sign in a `Mul` or `Div`, it builds `Select(b >= 0, ...)` to pick 
the bound order. The zero in that comparison was written as 
`IntImm(b->min_value.ty().WithLanes(1), 0)`, which aborts when `b` is a float 
expression:
   
   ```
   Check failed: (value_ty.MatchesCode(kDLInt, kDLUInt, kDLBool)) is false:
   IntImm supports only int or uint or bool type, but float32 was supplied.
   ```
   
   Bounded float intervals come from casting an integer iterator, which is 
exactly what TOPI resize does when it computes `float(x) * (in / out)`. As a 
result, lowering a linear `resize2d` whose output size is a symbolic multiple 
of the input, such as `(2 * H, 3 * W)`, crashes in `LowerIntrin`:
   
   ```python
   import tvm
   from tvm import te, topi
   
   H, W = tvm.tirx.Var("H", "int64"), tvm.tirx.Var("W", "int64")
   x = te.placeholder((2, 3, H, W), "float32")
   y = topi.image.resize2d(x, [0.0] * 4, (H * 2, W * 3), "NCHW", "linear", 
"asymmetric", "")
   tvm.compile(tvm.IRModule({"main": te.create_prim_func([x, y])}), 
target="llvm")
   ```
   
   The same crash is reachable at the analyzer level with 
`analyzer.int_set(float(i) * y, {i: [0, 4]})`. The fix builds the zero with 
`MakeConstScalar`, so it matches the operand type. For integer operands this 
produces the same `IntImm` as before, and for floats the branch previously 
always aborted, so no existing result changes. The `FloorDiv` site is 
integer-only and is updated only for consistency.
   
   The new test checks the resulting `Mul` and `Div` bounds for positive and 
negative values of the unknown-sign operand. With the fix, the resize example 
above compiles and runs, and the `tests/python/sym` suite passes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to