diff --git a/python/paddle/fluid/tests/unittests/test_poisson_op.py b/python/paddle/fluid/tests/unittests/test_poisson_op.py index 812770fac3ae4ba436d85e5af28e1bacd8728641..03259e8d5a146c5bcb26532e53ad893c2a640b91 100644 --- a/python/paddle/fluid/tests/unittests/test_poisson_op.py +++ b/python/paddle/fluid/tests/unittests/test_poisson_op.py @@ -39,13 +39,14 @@ def output_hist(out, lam, a, b): class TestPoissonOp1(OpTest): + def setUp(self): self.op_type = "poisson" self.config() self.attrs = {} - self.inputs = {'X': np.full([1024, 1024], self.lam, dtype=self.dtype)} - self.outputs = {'Out': np.ones([1024, 1024], dtype=self.dtype)} + self.inputs = {'X': np.full([2048, 1024], self.lam, dtype=self.dtype)} + self.outputs = {'Out': np.ones([2048, 1024], dtype=self.dtype)} def config(self): self.lam = 10 @@ -55,10 +56,8 @@ class TestPoissonOp1(OpTest): def verify_output(self, outs): hist, prob = output_hist(np.array(outs[0]), self.lam, self.a, self.b) - self.assertTrue( - np.allclose( - hist, prob, rtol=0.01), - "actual: {}, expected: {}".format(hist, prob)) + self.assertTrue(np.allclose(hist, prob, rtol=0.01), + "actual: {}, expected: {}".format(hist, prob)) def test_check_output(self): self.check_output_customized(self.verify_output) @@ -67,22 +66,23 @@ class TestPoissonOp1(OpTest): self.check_grad( ['X'], 'Out', - user_defined_grads=[np.zeros( - [1024, 1024], dtype=self.dtype)], + user_defined_grads=[np.zeros([2048, 1024], dtype=self.dtype)], user_defined_grad_outputs=[ - np.random.rand(1024, 1024).astype(self.dtype) + np.random.rand(2048, 1024).astype(self.dtype) ]) class TestPoissonOp2(TestPoissonOp1): + def config(self): self.lam = 5 self.a = 1 - self.b = 9 + self.b = 8 self.dtype = "float32" class TestPoissonAPI(unittest.TestCase): + def test_static(self): with paddle.static.program_guard(paddle.static.Program(), paddle.static.Program()):