|
|
@ -83,36 +83,36 @@ class TestDropoutOp5(OpTest):
|
|
|
|
self.check_output()
|
|
|
|
self.check_output()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestFP16DropoutOp1(OpTest):
|
|
|
|
class TestFP16DropoutOp(OpTest):
|
|
|
|
def setUp(self):
|
|
|
|
def setUp(self):
|
|
|
|
x = np.random.random((32, 64)).astype("float16")
|
|
|
|
|
|
|
|
prob = 0.35
|
|
|
|
|
|
|
|
out = x * (1.0 - prob)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self.op_type = "dropout"
|
|
|
|
self.op_type = "dropout"
|
|
|
|
|
|
|
|
self.init_test_case()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
x = np.random.random(self.input_size).astype("float16")
|
|
|
|
|
|
|
|
out = x * (1.0 - self.prob)
|
|
|
|
self.inputs = {'X': OpTest.np_dtype_to_fluid_dtype(x)}
|
|
|
|
self.inputs = {'X': OpTest.np_dtype_to_fluid_dtype(x)}
|
|
|
|
self.attrs = {'dropout_prob': prob, 'fix_seed': True, 'is_test': True}
|
|
|
|
self.attrs = {
|
|
|
|
|
|
|
|
'dropout_prob': self.prob,
|
|
|
|
|
|
|
|
'fix_seed': self.fix_seed,
|
|
|
|
|
|
|
|
'is_test': True
|
|
|
|
|
|
|
|
}
|
|
|
|
self.outputs = {'Out': out}
|
|
|
|
self.outputs = {'Out': out}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def init_test_case(self):
|
|
|
|
|
|
|
|
self.input_size = [32, 64]
|
|
|
|
|
|
|
|
self.prob = 0.35
|
|
|
|
|
|
|
|
self.fix_seed = True
|
|
|
|
|
|
|
|
|
|
|
|
def test_check_output(self):
|
|
|
|
def test_check_output(self):
|
|
|
|
if core.is_compiled_with_cuda() and core.op_support_gpu("dropout"):
|
|
|
|
if core.is_compiled_with_cuda() and core.op_support_gpu("dropout"):
|
|
|
|
self.check_output_with_place(core.CUDAPlace(0), atol=1e-3)
|
|
|
|
self.check_output_with_place(core.CUDAPlace(0), atol=1e-3)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestFP16DropoutOp2(OpTest):
|
|
|
|
class TestFP16DropoutOp2(TestFP16DropoutOp):
|
|
|
|
def setUp(self):
|
|
|
|
def init_test_case(self):
|
|
|
|
x = np.random.random((32, 64, 3)).astype("float16")
|
|
|
|
self.input_size = [32, 64, 3]
|
|
|
|
prob = 0.75
|
|
|
|
self.prob = 0.75
|
|
|
|
out = x * (1.0 - prob)
|
|
|
|
self.fix_seed = False
|
|
|
|
|
|
|
|
|
|
|
|
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__':
|
|
|
|
if __name__ == '__main__':
|
|
|
|