-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[TIR][Schedule] Improve cache_index to cache common subexpressions #13700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
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 by @-ing them in a comment.
Generated by tvm-bot |
9b75cbc to
9bde9d8
Compare
66f3b2d to
2a804ef
Compare
python/tvm/tir/schedule/schedule.py
Outdated
| self, | ||
| block: Union[BlockRV, str], | ||
| storage_scope: str, | ||
| cse_thresh: int, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we set a default value for cse_thresh? e.g. 0/-1 for not enabling cse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we set a default value for
cse_thresh? e.g. 0/-1 for not enabling cse?
OK, I'll set 0 as caching all the index computation for the target block, should be useful for simple cases and expensive in complex cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's done. @Hzfengsy
2a804ef to
6a329c2
Compare
Much of the index computation is duplicated, so this PR is to do common subexpression analyze when performing cache_index. A threshold number is needed when identifying a common sub expr, since we only want to cache the most frequently appeared sub expressions. And an arith helper function is added to help analyze the target expr. A common use case may be calling tvm.arith.detect_common_subexpr() and determining based on its result whether to perform cache_index and its corresponding threshold.
6a329c2 to
c62b8d2
Compare
…pache#13700) Much of the index computation is duplicated, so this PR is to do common subexpression analyze when performing cache_index. A threshold number is needed when identifying a common sub expr, since we only want to cache the most frequently appeared sub expressions. And an arith helper function is added to help analyze the target expr. A common use case may be calling tvm.arith.detect_common_subexpr() and determining based on its result whether to perform cache_index and its corresponding threshold. Co-authored-by: Min Chen <chen.min@intellif.com>
Much of the index computation is duplicated, so this PR is to do common subexpression analyze when performing cache_index.
And because all block var related computation could be cached, buffer-based cache is somehow too restrictive. So here make it block-based.
A threshold number is needed when identifying a common sub expr, since we only want to cache the most frequently appeared sub expressions. A common use case may be like this: calling tvm.arith.detect_common_subexpr() and determining based on its result whether to perform cache_index and its corresponding threshold.
cc @wrongtest-intellif @Hzfengsy