-
Notifications
You must be signed in to change notification settings - Fork 836
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
Add int16 support to RELU #2727
base: main
Are you sure you want to change the base?
Conversation
TF_LITE_MICRO_TEST(SimpleReluTestInt16) { | ||
const int elements_count = 10; | ||
|
||
int input_shape[] = {2, 1, 5}; |
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.
This should be 2, 2, 5
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
int input_shape[] = {2, 1, 5}; | ||
const float input_data[] = {1, 2, 3, 4, 5, -1, -2, -3, -4, -5}; | ||
int16_t input_quantized[elements_count]; | ||
int output_shape[] = {2, 1, 5}; |
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.
This should be 2, 2, 5
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
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.
In ReluPrepare
the following code should be used to conform with TfLite (LiteRT):
if (input->type == kTfLiteInt8) {
CalculateReluOpData<int8_t>(input, output, data);
}
else if (input->type == kTfLiteInt16) {
TF_LITE_ENSURE_EQ(context, input->params.zero_point, 0);
TF_LITE_ENSURE_EQ(context, output->params.zero_point, 0);
CalculateReluOpData<int16_t>(input, output, data);
}
I am very surprised (and concerned) that the unit test passed, even though CalculateReluIOpData<int16_t>
was not being called.
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 might have had something to do with the chosen input data values. I changed them so that they need to are actually int16 values and then the test failed. Could be just a coincidence that it happened to work or there might be something else going elsewhere
Thank you for submitting this PR. I have flagged the errors in the kernel and unit test above. On to @suleshahid for approval. |
"This PR is being marked as stale due to inactivity. Remove label or comment to prevent closure in 5 days." |
Waiting for approval |
This PR adds int16 support to RELU
bug=#2726