[quantize] fix bug of annotate for output of add op#15529
Merged
masahi merged 7 commits intoapache:mainfrom Aug 14, 2023
Merged
[quantize] fix bug of annotate for output of add op#15529masahi merged 7 commits intoapache:mainfrom
masahi merged 7 commits intoapache:mainfrom
Conversation
The type of add op`s output is activation, it should annotate by QAnnotateKind.ACTIVATION. If not, the graph will cast int32 into int8 directly without quantized, when quantize resnet.
Collaborator
|
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 |
cbalint13
requested changes
Aug 11, 2023
Contributor
Author
Sure, I will do it |
Contributor
Author
|
@cbalint13 |
cbalint13
approved these changes
Aug 12, 2023
Contributor
cbalint13
left a comment
There was a problem hiding this comment.
@MingkangW ,
LGTM, thank you !
cbalint13
approved these changes
Aug 12, 2023
Contributor
Author
|
PTAL @cbalint13 @tqchen |
cbalint13
approved these changes
Aug 14, 2023
Contributor
Author
|
cc: @masahi |
masahi
approved these changes
Aug 14, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The type of add op
s output is activation, it should annotate by QAnnotateKind.ACTIVATION. If not, the graph will cast int32 into int8 directly without quantized, when quantize resnet. It will product overflow error, and it wont prompt when infer the model. The resnet18_v1 test case is below.before fixed
%703 = add(%701, %702) /* ty=Tensor[(1, 512, 7, 7), int32] /;
%704 = nn.relu(%703) / ty=Tensor[(1, 512, 7, 7), int32] /;
%705 = cast(%704, dtype="int8") / ty=Tensor[(1, 512, 7, 7), int8] /;
%706 = annotation.stop_fusion(%705) / ty=Tensor[(1, 512, 7, 7), int8] /;
after fixed
%443 = add(%441, %442) / ty=Tensor[(1, 512, 7, 7), int32] /;
%444 = nn.relu(%443) / ty=Tensor[(1, 512, 7, 7), int32] /;
%445 = cast(%444, dtype="int64") / ty=Tensor[(1, 512, 7, 7), int64] /;
%446 = fixed_point_multiply(%445, multiplier=1439683968, shift=-2) / ty=Tensor[(1, 512, 7, 7), int64] /;
%447 = clip(%446, a_min=-127f, a_max=127f) / ty=Tensor[(1, 512, 7, 7), int64] /;
%448 = cast(%447, dtype="int32") / ty=Tensor[(1, 512, 7, 7), int32] /;
%449 = cast(%448, dtype="int8") / ty=Tensor[(1, 512, 7, 7), int8] /;
%450 = annotation.stop_fusion(%449) / ty=Tensor[(1, 512, 7, 7), int8] */;