diff --git a/python/paddle/fluid/tests/unittests/test_cast_op.py b/python/paddle/fluid/tests/unittests/test_cast_op.py index 9c6ab00c85f8a6f735d1fab847c86f03664ee0d6..b8d3ed3aa3eb0e47e79f46cdf681a3b9cca46036 100644 --- a/python/paddle/fluid/tests/unittests/test_cast_op.py +++ b/python/paddle/fluid/tests/unittests/test_cast_op.py @@ -40,7 +40,7 @@ class TestCastOp2(op_test.OpTest): def setUp(self): ipt = np.random.random(size=[10, 10]) # 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.attrs = { 'in_dtype': int(core.VarDesc.VarType.FP16), @@ -49,10 +49,10 @@ class TestCastOp2(op_test.OpTest): self.op_type = 'cast' 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): ipt = np.random.random(size=[10, 10]) self.inputs = {'X': ipt.astype('float32')} @@ -64,7 +64,7 @@ class TestCastOp2(op_test.OpTest): self.op_type = 'cast' def test_check_output(self): - self.check_output() + self.check_output(atol=1e-3) if __name__ == '__main__':