-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[AMP OP&Test]Add fp16/bf16 support isnan/isfinite/isinf op #52259
Merged
Merged
Changes from 3 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a5c6217
add bfp16 test for isfinite
wjj19950828 19c2a2b
fixed for ci
wjj19950828 3ffc408
Merge remote-tracking branch 'upstream/develop' into isfinite_amp
wjj19950828 8ce17dd
Merge remote-tracking branch 'upstream/develop' into isfinite_amp
wjj19950828 0d38e8f
deal with comments
wjj19950828 b421a4f
fixed test
wjj19950828 10b0b28
Merge remote-tracking branch 'upstream/develop' into isfinite_amp
wjj19950828 392d130
skip test in cpu
wjj19950828 683025e
Merge remote-tracking branch 'upstream/develop' into isfinite_amp
wjj19950828 2e9a282
Merge remote-tracking branch 'upstream/develop' into isfinite_amp
wjj19950828 f1c63e4
deal with comments
wjj19950828 3035784
Merge remote-tracking branch 'upstream/develop' into isfinite_amp
wjj19950828 c764891
fixed for ci
wjj19950828 8a6d644
fixed testcase
wjj19950828 59f9bde
fixed for ci
wjj19950828 008ef13
Merge remote-tracking branch 'upstream/develop' into isfinite_amp
wjj19950828 7307715
fixed for testcase
wjj19950828 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
import numpy as np | ||
from eager_op_test import OpTest | ||
from op_test import convert_float_to_uint16 | ||
|
||
from paddle.fluid import core | ||
|
||
|
@@ -48,6 +49,23 @@ def init_dtype(self): | |
self.dtype = np.float16 | ||
|
||
|
||
# BFP16 isinf Test | ||
class TestInfBF16(OpTest): | ||
def setUp(self): | ||
self.op_type = "isinf" | ||
self.dtype = np.uint16 | ||
x = np.random.uniform(0.1, 1, [11, 17]).astype(np.float32) | ||
x[0] = np.inf | ||
x[-1] = np.inf | ||
|
||
out = np.isinf(x).astype(np.float32) | ||
self.inputs = {'X': convert_float_to_uint16(x)} | ||
self.outputs = {'Out': convert_float_to_uint16(out)} | ||
|
||
def test_output(self): | ||
self.check_output() | ||
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. 这里需要直接调用check_output_with_place,不然CPU的place会报错 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. Done. |
||
|
||
|
||
class TestNAN(OpTest): | ||
def setUp(self): | ||
self.op_type = "isnan" | ||
|
@@ -76,6 +94,23 @@ def init_dtype(self): | |
self.dtype = np.float16 | ||
|
||
|
||
# BFP16 isnan Test | ||
class TestNANBF16(OpTest): | ||
def setUp(self): | ||
self.op_type = "isnan" | ||
self.dtype = np.uint16 | ||
x = np.random.uniform(0.1, 1, [11, 17]).astype(np.float32) | ||
x[0] = np.nan | ||
x[-1] = np.nan | ||
|
||
out = np.isnan(x).astype(np.float32) | ||
self.inputs = {'X': convert_float_to_uint16(x)} | ||
self.outputs = {'Out': convert_float_to_uint16(out)} | ||
|
||
def test_output(self): | ||
self.check_output() | ||
|
||
|
||
class TestIsfinite(OpTest): | ||
def setUp(self): | ||
self.op_type = "isfinite" | ||
|
@@ -105,5 +140,22 @@ def init_dtype(self): | |
self.dtype = np.float16 | ||
|
||
|
||
# BFP16 isfinite Test | ||
class TestIsfiniteBF16(OpTest): | ||
def setUp(self): | ||
self.op_type = "isfinite" | ||
self.dtype = np.uint16 | ||
x = np.random.uniform(0.1, 1, [11, 17]).astype(np.float32) | ||
x[0] = np.inf | ||
x[-1] = np.nan | ||
|
||
out = np.isfinite(x).astype(np.float32) | ||
self.inputs = {'X': convert_float_to_uint16(x)} | ||
self.outputs = {'Out': convert_float_to_uint16(out)} | ||
|
||
def test_output(self): | ||
self.check_output() | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
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
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.
从
eager_op_test
中importThere 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.