-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Reimplement ReLu6 in the backends and frontends #10587
Merged
MahmoudAshraf97
merged 13 commits into
ivy-llc:master
from
MahmoudAshraf97:tensorflow.nn.relu6
Feb 25, 2023
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3350e40
initial addition of relu6 in all backends
MahmoudAshraf97 d253cb2
switch old relu6 calls with new ivy.relu6
MahmoudAshraf97 64f332e
added test for tf.nn.relu6
MahmoudAshraf97 ecfb095
moved relu6 in all backends to experimental
MahmoudAshraf97 aaae6ed
added backend test, relu6 method for arrays and containers, fixed sup…
MahmoudAshraf97 5498daa
revert unrelated formatting changes
MahmoudAshraf97 bacd76f
revert unrelated formatting changes
MahmoudAshraf97 82e0b79
switch Relu6 to tf.nn alias
MahmoudAshraf97 6c2d2e7
add unsupported dtypes for relu6
MahmoudAshraf97 b58a951
fix jax casting to adhere to superset behaviour
MahmoudAshraf97 ea79d53
update safety factor, change `get_dtypes` to numeric.
CatB1t 339d8cb
update jax.nn.relu6 to fix gradients at boundary conditions
MahmoudAshraf97 c1fbad2
Merge branch 'master' into tensorflow.nn.relu6
MahmoudAshraf97 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,7 +172,7 @@ def threshold_(input, threshold, value): | |
|
||
|
||
def relu6(input, inplace=False): | ||
ret = ivy.minimum(ivy.maximum(input, 0), 6) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, this one also fails for JAX backend. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same problem as other two tests |
||
ret = ivy.relu6(input) | ||
if inplace: | ||
ivy.inplace_update(input, ret) | ||
return input | ||
|
@@ -307,7 +307,7 @@ def leaky_relu_(input, negative_slope=0.01): | |
|
||
|
||
def hardswish(input, inplace=False): | ||
relu6_val = ivy.minimum(ivy.maximum(ivy.add(input, 3), 0), 6) | ||
relu6_val = ivy.relu6(ivy.add(input, 3)) | ||
ret = ivy.multiply(input, ivy.divide(relu6_val, 6)) | ||
if inplace: | ||
ivy.inplace_update(input, ret) | ||
|
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
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
Oops, something went wrong.
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.
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.
The frontend tests fail here, could you have a look?
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.
Fixed, althought the tests still fail with jax backend due to different return Dtype, this is a problem with all activation functions that use any Dtype other than float such as numerical
also sometimes fails with torch backend when float16 is used although the @with_unsupported_dtypes dtype is used