-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
[IE][nGraph] resolve division by zero for FP16 #8676
Merged
rkazants
merged 10 commits into
openvinotoolkit:master
from
pavel-esir:resolve_division_to_zero
Dec 7, 2021
Merged
[IE][nGraph] resolve division by zero for FP16 #8676
rkazants
merged 10 commits into
openvinotoolkit:master
from
pavel-esir:resolve_division_to_zero
Dec 7, 2021
Conversation
This file contains 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
0ee15e5
to
c4aa420
Compare
11 tasks
sadolini
approved these changes
Nov 30, 2021
rkazants
reviewed
Dec 1, 2021
...nsformations/include/transformations/common_optimizations/division_to_zero_fp16_resolver.hpp
Outdated
Show resolved
Hide resolved
rkazants
reviewed
Dec 1, 2021
.../transformations/src/transformations/common_optimizations/division_to_zero_fp16_resolver.cpp
Outdated
Show resolved
Hide resolved
rkazants
reviewed
Dec 1, 2021
.../transformations/src/transformations/common_optimizations/division_to_zero_fp16_resolver.cpp
Outdated
Show resolved
Hide resolved
rkazants
reviewed
Dec 1, 2021
...ne/tests/functional/inference_engine/transformations/division_to_zero_fp16_resolver_test.cpp
Outdated
Show resolved
Hide resolved
rkazants
reviewed
Dec 1, 2021
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 do like the solution
achetver
approved these changes
Dec 2, 2021
…e minor corrections
rkazants
approved these changes
Dec 2, 2021
GlebKazantaev
suggested changes
Dec 6, 2021
.../transformations/src/transformations/common_optimizations/division_by_zero_fp16_resolver.cpp
Outdated
Show resolved
Hide resolved
.../transformations/src/transformations/common_optimizations/division_by_zero_fp16_resolver.cpp
Outdated
Show resolved
Hide resolved
|
||
/** | ||
* @ingroup ie_transformation_common_api | ||
* @brief: clamps eps into fp16 minimal normalized value in input_1/Maximum(input_2, eps); input_1/Add(input_2, eps); |
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: looks like this is not al patterns that are supported. Better to keep patterns description in cpp.
GlebKazantaev
approved these changes
Dec 7, 2021
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.
Root cause analysis: In some models patterns
x/max(y, eps)
andx/(y + eps)
are used to prevent division by zero. But usually in FP32 networks eps is such small (e.g. 1e-9, 1e-12, ...) that after casting to FP16 it's collapsed to zero. This can lead to division by zero ifx
andy
happen to be also zero.Solution: To prevent that in such patterns we change eps to FP16 smallest normalized value (0.0000610.., details in Half_precision_examples) in transformation
DivisionByZeroFP16Resolver
.Tickets:
Ticket: CVS-66045, CVS-65735
Code:
Validation: