-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Relay] improve SimplifyClipAndConsecutiveCast pass #15362
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 |
Perhaps the failure of test is due to the optimization of this PR: this PR may reduce the memory the model requires. |
For now I just modify the ground truth of the test case to pass tests. Not sure if this is correct. Correct me if the original ground truth is indeed correct. |
@@ -160,7 +160,7 @@ class SimplifyConsecutiveCast : public DFPatternRewrite { | |||
DFPattern cast1_; | |||
}; | |||
|
|||
bool CheckDataTypeMaxMinValue(DataType dtype, double min_value, double max_value) { | |||
bool CheckDataTypeMaxMinValue(DataType dtype, double min_value, double max_value, int mode = 0) { |
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.
Please comment the meaning of different mode
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.
Done
This PR improves SimplifyClipAndConsecutiveCast pass in several aspects.
First, it allows that the dtype of
clip
and the dtype of the lastcast
differ.Second, it allows that there are arbitrary number of
cast
afterclip
. This is achieved via the recursion of patterns.Both of the above two cases araise from the compilation of a prequantized model.
See the pre-RFC