You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by "Lucien0 (via GitHub)" <gi...@apache.org> on 2023/08/15 07:32:45 UTC
[GitHub] [tvm] Lucien0 opened a new pull request, #15558: [Arith] Fix detect linear equation with uint var
Lucien0 opened a new pull request, #15558:
URL: https://github.com/apache/tvm/pull/15558
Hi, the following code encounters an error while executing
```
c = te.var("c", "uint32")
m = tvm.arith.detect_linear_equation(128 - c, [c])
```
It seems that when creating coefficients for var, it always uses var's dtype, which doesn't seem very reasonable. Even if var itself is uint, its coefficient is likely to be negative.
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] tqchen commented on pull request #15558: [Arith] Fix detect linear equation with uint var
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on PR #15558:
URL: https://github.com/apache/tvm/pull/15558#issuecomment-1679080348
we always suggest only using signed integer for index calculations(and provide analysis to detect their signs) to avoid cases like underflow
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] tqchen merged pull request #15558: [Arith] Fix detect linear equation with uint var
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen merged PR #15558:
URL: https://github.com/apache/tvm/pull/15558
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] Johnson9009 commented on pull request #15558: [Arith] Fix detect linear equation with uint var
Posted by "Johnson9009 (via GitHub)" <gi...@apache.org>.
Johnson9009 commented on PR #15558:
URL: https://github.com/apache/tvm/pull/15558#issuecomment-1690265739
@tqchen @junrushao @Hzfengsy Can help to continue review this PR? Thanks.
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] tvm-bot commented on pull request #15558: [Arith] Fix detect linear equation with uint var
Posted by "tvm-bot (via GitHub)" <gi...@apache.org>.
tvm-bot commented on PR #15558:
URL: https://github.com/apache/tvm/pull/15558#issuecomment-1678532044
<!---bot-comment-->
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @-ing them in a comment.
<!--bot-comment-ccs-start-->
* cc @junrushao <sub>See [#10317](https://github.com/apache/tvm/issues/10317) for details</sub><!--bot-comment-ccs-end-->
<sub>Generated by [tvm-bot](https://github.com/apache/tvm/blob/main/ci/README.md#github-actions)</sub>
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] tqchen commented on pull request #15558: [Arith] Fix detect linear equation with uint var
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on PR #15558:
URL: https://github.com/apache/tvm/pull/15558#issuecomment-1691560789
I would like to add up saying that it is strongly preferable to use signed integers, since unlikely we will be able to have robust arith for all dtypes, mainly because the unsigned arith have underflow issues. So while it is fine to land some cases like this one. I would still strongly recommend to use signed int for most cases
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] Johnson9009 commented on pull request #15558: [Arith] Fix detect linear equation with uint var
Posted by "Johnson9009 (via GitHub)" <gi...@apache.org>.
Johnson9009 commented on PR #15558:
URL: https://github.com/apache/tvm/pull/15558#issuecomment-1679875028
> Thank you @Lucien0 . we always suggest only using signed integer for index calculations(and provide analysis to detect their signs, or declare as size_var, which is signed but ensures to be non-negative) to avoid cases like underflow. This is because in a lot of cases unsigned integer can have surprises. I know it is not properly documented, so maybe a better approach is to document this rationale in the arith function docs.
>
> Having this explicit choice helps to simplify our implementations and avoid other surprise cases
Thanks @tqchen for the comment, let me explain some background information, current we are actively develop our DSL based on TVM script for our ARM China Zhouyi NPU, during these years we try to land TVM DSL(TE, Hybrid script, ir builder) to NPU, the result isn't good, because all of these methods can't act as a role of C/Open CL replacer, even though we can reach better performance for some operators, but still have some operator need to write by the operator library developers. Until now we have time to continue the DSL work for our NPU, and we find TVM script can do whatever C/Open CL language do in theory, so we change our DSL solution to TVM Script based, we think this work have the potential to be a good demo for TIR on NPU (scalar small CPU+ SIMD VPU + MAC arry) like what BYOC does.
I totally agree we should prefer signed integer for programming, but we can't avoid the DSL user use unsigned var like the sample code shown, and more real senario is we have lots of variables and maybe one of them is unsigned and lead to the others that depend on it become unsigned, the current code will give wrong result instead of unoptimized result, so I think if this fix can be accept, because at least it can fix the wrong result? And does this fix have some side effect?
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [tvm] tqchen commented on pull request #15558: [Arith] Fix detect linear equation with uint var
Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on PR #15558:
URL: https://github.com/apache/tvm/pull/15558#issuecomment-1691558080
Thanks for the input. Given the change is simple happy to merge it in
--
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: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org