-
Notifications
You must be signed in to change notification settings - Fork 961
Add check that output is quantized. #1830
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
emmett-google
left a comment
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.
Suggestion to move the check into CalculateOpDataAdd but otherwise looks good!
| // This is to ensure that for int8/int16 output type,output does not have | ||
| // a "no-quantization" quantization type. | ||
| if (output->type == kTfLiteInt8 || output->type == kTfLiteInt16) { | ||
| TFLITE_CHECK_NE(output->quantization.type, kTfLiteNoQuantization); |
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.
I'd suggest moving this into CalculateOpDataAdd in Line 42 for a few long term maintenance reasons:
- The assert is closer to the code that assumes quantization.
- One fewer branch to maintain for checking output types. If someone extends the branch logic in
CalculateOpDataAdd, it will only need to be changed in on place.
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.
Thank you for the suggestion! Made the change.
| data->requires_broadcast = !HaveSameShapes(input1, input2); | ||
|
|
||
| if (output->type == kTfLiteInt8 || output->type == kTfLiteInt16) { | ||
| // This is to ensure that for int8/int16 output type,output does not have |
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.
Nit: Remove the comment. It's basically explaining the code.
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.
BUG=http://b/267818294