-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Add float16 support to dropout operator #9223
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
Changes from 5 commits
05ad158
d03dbb9
18d616e
f2bbbb2
182da95
509c839
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
|
|
||
| import unittest | ||
| import numpy as np | ||
| import paddle.fluid.core as core | ||
| from op_test import OpTest | ||
|
|
||
|
|
||
|
|
@@ -82,5 +83,37 @@ def test_check_output(self): | |
| self.check_output() | ||
|
|
||
|
|
||
| class TestFP16DropoutOp1(OpTest): | ||
| def setUp(self): | ||
| x = np.random.random((32, 64)).astype("float16") | ||
| prob = 0.35 | ||
| out = x * (1.0 - prob) | ||
|
|
||
| self.op_type = "dropout" | ||
| self.inputs = {'X': OpTest.np_dtype_to_fluid_dtype(x)} | ||
| self.attrs = {'dropout_prob': prob, 'fix_seed': True, 'is_test': True} | ||
| self.outputs = {'Out': out} | ||
|
|
||
| def test_check_output(self): | ||
| if core.is_compiled_with_cuda() and core.op_support_gpu("dropout"): | ||
| self.check_output_with_place(core.CUDAPlace(0), atol=1e-3) | ||
|
|
||
|
|
||
| class TestFP16DropoutOp2(OpTest): | ||
| def setUp(self): | ||
| x = np.random.random((32, 64, 3)).astype("float16") | ||
| prob = 0.75 | ||
| out = x * (1.0 - prob) | ||
|
|
||
| self.op_type = "dropout" | ||
| self.inputs = {'X': OpTest.np_dtype_to_fluid_dtype(x)} | ||
| self.attrs = {'dropout_prob': prob, 'is_test': True} | ||
| self.outputs = {'Out': out} | ||
|
|
||
| def test_check_output(self): | ||
| if core.is_compiled_with_cuda() and core.op_support_gpu("dropout"): | ||
| self.check_output_with_place(core.CUDAPlace(0), atol=1e-3) | ||
|
||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| unittest.main() | ||
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.
Maybe
HOSTis unnecessary.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 guess so. Let me fix that in the next PR.