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

[TFLite] Update MultiplyByQuantizedMultiplier to use single-rounding instead of double-rounding #50290

Merged
merged 21 commits into from
Dec 9, 2021

Conversation

Tessil
Copy link
Contributor

@Tessil Tessil commented Jun 15, 2021

Hello,

This PR changes the rounding of the int32 MultiplyByQuantizedMultiplier methods to a single-rounding instead of a double-rounding in a way similar to what was done in google/ruy#227 and adapts the tests to the change.

The new int32 MultiplyByQuantizedMultiplier adds a restriction on the quantized multiplier, it must now be a positive integer in the same way as in the int64 version of MultiplyByQuantizedMultiplier. This restriction also matches the one in the quantization scaling defined in the TOSA specification. To achieve that the SUB and DIV operators were slightly adapted to avoid any negative quantized multiplier.

Thibaut

@google-ml-butler google-ml-butler bot added the size:L CL Change Size: Large label Jun 15, 2021
@google-cla google-cla bot added the cla: yes label Jun 15, 2021
@abattery abattery requested a review from renjie-liu June 16, 2021 00:21
@gbaned gbaned self-assigned this Jun 16, 2021
@gbaned gbaned added the comp:lite TF Lite related issues label Jun 16, 2021
@gbaned gbaned added this to Assigned Reviewer in PR Queue via automation Jun 16, 2021
@jdduke jdduke requested a review from jianlijianli June 16, 2021 14:52
… outputs

The change provides a more in-depth testing of the SUB operator. Previously the same scaling was used for both inputs and for the output, a simple subtraction in the kernel without any rescaling would have made the tests pass.
@renjie-liu renjie-liu requested a review from bjacob June 17, 2021 02:51
@gbaned gbaned requested a review from renjie-liu July 2, 2021 18:16
@gbaned gbaned added the awaiting review Pull request awaiting review label Jul 2, 2021
Copy link
Member

@renjie-liu renjie-liu left a comment

Choose a reason for hiding this comment

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

lgtm, please wait for others' opinions as well, thanks!

tensorflow/lite/kernels/internal/common.h Show resolved Hide resolved
tensorflow/lite/kernels/internal/reference/sub.h Outdated Show resolved Hide resolved
tensorflow/lite/kernels/internal/common.h Outdated Show resolved Hide resolved
@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Jul 3, 2021
PR Queue automation moved this from Assigned Reviewer to Approved by Reviewer Jul 3, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Jul 3, 2021
@google-ml-butler google-ml-butler bot removed the ready to pull PR ready for merge process label Jul 5, 2021
@Tessil
Copy link
Contributor Author

Tessil commented Jul 5, 2021

Thank you for the review.

@renjie-liu I split the PR in two. The #50615 PR changes the SUB and DIV kernels to avoid the usage of negative quantized multipliers in MultiplyByQuantizedMuliplier and I left this one to concentrate on the MultiplyByQuantizedMuliplier rounding changes and the tests adaptation. The first one should be merged before this one for the tests to pass.

@gbaned gbaned added the kokoro:force-run Tests on submitted change label Nov 17, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Nov 17, 2021
@gbaned
Copy link
Contributor

gbaned commented Nov 18, 2021

@Tessil Can you please address Ubuntu Sanity errors? Thanks!

@gbaned gbaned removed the ready to pull PR ready for merge process label Nov 18, 2021
@Tessil
Copy link
Contributor Author

Tessil commented Nov 18, 2021

@gbaned Thanks, the latest commit should fix it.

@gbaned gbaned added the kokoro:force-run Tests on submitted change label Nov 19, 2021
@kokoro-team kokoro-team removed kokoro:force-run Tests on submitted change labels Nov 19, 2021
@google-ml-butler google-ml-butler bot added the awaiting review Pull request awaiting review label Nov 19, 2021
Copy link
Contributor

@jianlijianli jianlijianli left a comment

Choose a reason for hiding this comment

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

Thanks Tessil.

@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Nov 30, 2021
@kokoro-team kokoro-team removed kokoro:force-run Tests on submitted change labels Nov 30, 2021
@tensorflowbutler tensorflowbutler removed the awaiting review Pull request awaiting review label Dec 2, 2021
@gbaned gbaned removed the ready to pull PR ready for merge process label Dec 2, 2021
@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Dec 2, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Dec 2, 2021
@gbaned gbaned added ready to pull PR ready for merge process and removed ready to pull PR ready for merge process labels Dec 3, 2021
@copybara-service copybara-service bot merged commit 9af339b into tensorflow:master Dec 9, 2021
@google-ml-butler google-ml-butler bot removed the ready to pull PR ready for merge process label Dec 9, 2021
mansnils added a commit to mansnils/CMSIS_5 that referenced this pull request Dec 14, 2021
Adapt to Tflite/TfliteMicro, which will use single rounding instead of double rounding:
tensorflow/tensorflow#50290

Changes are added under flag CMSIS_NN_USE_SINGLE_ROUNDING, which is
disabled by default.
mansnils added a commit to ARM-software/CMSIS_5 that referenced this pull request Jan 3, 2022
Adapt to Tflite/TfliteMicro, which will use single rounding instead of double rounding:
tensorflow/tensorflow#50290

Changes are added under flag CMSIS_NN_USE_SINGLE_ROUNDING, which is
disabled by default.
felix-johnny pushed a commit to ARM-software/CMSIS-NN that referenced this pull request Oct 4, 2022
Adapt to Tflite/TfliteMicro, which will use single rounding instead of double rounding:
tensorflow/tensorflow#50290

Changes are added under flag CMSIS_NN_USE_SINGLE_ROUNDING, which is
disabled by default.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes comp:lite TF Lite related issues size:L CL Change Size: Large
Projects
PR Queue
  
Approved by Reviewer
Development

Successfully merging this pull request may close these issues.

None yet

9 participants