shanyi15-patch-2
Kexin Zhao 7 years ago
parent f3c5e81556
commit 6ef4f1f8c0

@ -40,7 +40,7 @@ class TestCastOp2(op_test.OpTest):
def setUp(self): def setUp(self):
ipt = np.random.random(size=[10, 10]) ipt = np.random.random(size=[10, 10])
# numpy float16 is binded to fluid float16 via uint16 # numpy float16 is binded to fluid float16 via uint16
self.inputs = {'X': ipt.astype('float16').view(uint16)} self.inputs = {'X': ipt.astype('float16').view(np.uint16)}
self.outputs = {'Out': ipt.astype('float32')} self.outputs = {'Out': ipt.astype('float32')}
self.attrs = { self.attrs = {
'in_dtype': int(core.VarDesc.VarType.FP16), 'in_dtype': int(core.VarDesc.VarType.FP16),
@ -49,10 +49,10 @@ class TestCastOp2(op_test.OpTest):
self.op_type = 'cast' self.op_type = 'cast'
def test_check_output(self): def test_check_output(self):
self.check_output() self.check_output(atol=1e-3)
class TestCastOp2(op_test.OpTest): class TestCastOp3(op_test.OpTest):
def setUp(self): def setUp(self):
ipt = np.random.random(size=[10, 10]) ipt = np.random.random(size=[10, 10])
self.inputs = {'X': ipt.astype('float32')} self.inputs = {'X': ipt.astype('float32')}
@ -64,7 +64,7 @@ class TestCastOp2(op_test.OpTest):
self.op_type = 'cast' self.op_type = 'cast'
def test_check_output(self): def test_check_output(self):
self.check_output() self.check_output(atol=1e-3)
if __name__ == '__main__': if __name__ == '__main__':

Loading…
Cancel
Save