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

[TFL] Fix unbounded activation clip range. #46991

Closed

Conversation

WindQAQ
Copy link
Member

@WindQAQ WindQAQ commented Feb 8, 2021

Fixes #45312. For floating point with unbounded activation such as relu and none, set max/min to positive/negative infinity in case infinity is clipped. The change only affects floating point as std::numeric_limits<T>::has_infinity is always false for non-floating point. Doing min(max(x, -inf), inf) is safe because positive infinity is larger than all values except itself and NaN and negative infinity is smaller than all values expect itself and NaN. With the change, TFLite is the same with TF for relu and none activation when input is positive or negative infinity.

https://www.gnu.org/software/libc/manual/html_node/Infinity-and-NaN.html
https://en.cppreference.com/w/cpp/types/numeric_limits/has_infinity

For floating point with unbounded activation such as relu and none, set max/min to positive/negative infinity in case infinity is clipped.
The change only affects floating point as std::numeric_limits<T>::has_infinity is always false for non-floating point.
@google-ml-butler google-ml-butler bot added the size:M CL Change Size: Medium label Feb 8, 2021
@google-cla google-cla bot added the cla: yes label Feb 8, 2021
@abattery abattery requested a review from thaink February 8, 2021 03:06
@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Feb 8, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Feb 8, 2021
@google-ml-butler google-ml-butler bot removed the ready to pull PR ready for merge process label Feb 8, 2021
@WindQAQ WindQAQ requested a review from abattery February 8, 2021 03:15
@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Feb 8, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Feb 8, 2021
@gbaned gbaned self-assigned this Feb 8, 2021
@gbaned gbaned added the prtype:bugfix PR to fix a bug label Feb 8, 2021
@gbaned gbaned added this to Assigned Reviewer in PR Queue via automation Feb 8, 2021
PR Queue automation moved this from Assigned Reviewer to Approved by Reviewer Feb 8, 2021
@google-ml-butler google-ml-butler bot added the kokoro:force-run Tests on submitted change label Feb 8, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Feb 8, 2021
@gbaned gbaned added the comp:lite TF Lite related issues label Feb 8, 2021
@rthadur rthadur added ready to pull PR ready for merge process and removed ready to pull PR ready for merge process labels Feb 8, 2021
@google-ml-butler google-ml-butler bot removed the ready to pull PR ready for merge process label Feb 9, 2021
@WindQAQ WindQAQ requested a review from abattery February 9, 2021 00:15
@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Feb 9, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Feb 9, 2021
@google-ml-butler google-ml-butler bot added the kokoro:force-run Tests on submitted change label Feb 9, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Feb 9, 2021
@thaink thaink self-requested a review February 9, 2021 01:35
@google-ml-butler google-ml-butler bot added the kokoro:force-run Tests on submitted change label Feb 9, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Feb 9, 2021
@thaink
Copy link
Member

thaink commented Feb 23, 2021

This PR will be hold until we can invest to make a thorough investigation about how current ops are handling inf value to ensure there is no compatibility issues.

@abattery abattery closed this Apr 19, 2022
PR Queue automation moved this from Approved by Reviewer to Closed/Rejected Apr 19, 2022
@google-ml-butler google-ml-butler bot removed the ready to pull PR ready for merge process label Apr 19, 2022
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 prtype:bugfix PR to fix a bug size:M CL Change Size: Medium
Projects
PR Queue
  
Closed/Rejected
Development

Successfully merging this pull request may close these issues.

TFlite gets the incorrect value dividing by zero or computing tf.log(x)
7 participants