Lunderberg commented on PR #16679: URL: https://github.com/apache/tvm/pull/16679#issuecomment-1983991434
I agree, it sounds like this is an issue where there's an insufficient condition, rather than a missing rewrite rule. If the test case is run without this PR, but providing the knowledge that `x > 0`, (`TestCase(tvm.te.min(0, fld(x + 3, 4) * 4 - 1), 0, x>0)` in the unit tests), then it passes. There's a couple different ways that assumptions can be added to the function. 1. Using the variable as a dynamic shape. This is already applied, but isn't a strong enough assumption to perform the simplifications you want. In your script, this would provide `m >= 0`, while the simplification requires `m > 0`. Since TIR allows a zero-dimension axis, this is the correct default behavior. 2. Adding `T.assume(m > 0)` to the function. Using `T.assume` provides additional information, but has undefined behavior if the assumption is violated. 3. Adding `T.Assert(m > 0, "Some error message here")` to the function. Using `T.Assert` performs a runtime validation, raising an exception if the assertion is violated. All compile-time simplifications after the `T.Assert` may assume that the assumption holds. I'd recommend using `T.Assert`, and only falling back to the `T.assume` if there are performance reasons to avoid the runtime validation. -- 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]
