Skip to content
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

Merged
merged 3 commits into from
Jul 23, 2023

Conversation

kfeng123
Copy link
Contributor

This PR improves SimplifyClipAndConsecutiveCast pass in several aspects.
First, it allows that the dtype of clip and the dtype of the last cast differ.
Second, it allows that there are arbitrary number of cast after clip. 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

@tvm-bot
Copy link
Collaborator

tvm-bot commented Jul 19, 2023

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

@kfeng123
Copy link
Contributor Author

Perhaps the failure of test is due to the optimization of this PR: this PR may reduce the memory the model requires.
I file a issue.
Hopefully, some experts of usmp may help to verify this issue.

@kfeng123
Copy link
Contributor Author

Perhaps the failure of test is due to the optimization of this PR: this PR may reduce the memory the model requires. I file a issue. Hopefully, some experts of usmp may help to verify this issue.

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) {
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@kfeng123 kfeng123 requested a review from Hzfengsy July 23, 2023 03:44
@Hzfengsy Hzfengsy merged commit 8babadb into apache:main Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants