Skip to content

Commit

Permalink
use paddle.data instead of fluid.data, test=develop
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangting2020 committed Aug 18, 2020
1 parent f24b5af commit 4916400
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions python/paddle/fluid/tests/unittests/test_allclose_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import numpy as np
from op_test import OpTest
import paddle
import paddle.fluid as fluid


class TestAllcloseOp(OpTest):
Expand Down Expand Up @@ -94,24 +93,26 @@ def test_api_case(self):
class TestAllcloseError(unittest.TestCase):
def test_input_dtype(self):
def test_x_dtype():
with fluid.program_guard(fluid.Program()):
x = fluid.data(name='x', shape=[10, 10], dtype='float16')
y = fluid.data(name='y', shape=[10, 10], dtype='float64')
with paddle.static.program_guard(paddle.static.Program(),
paddle.static.Program()):
x = paddle.data(name='x', shape=[10, 10], dtype='float16')
y = paddle.data(name='y', shape=[10, 10], dtype='float64')
result = paddle.allclose(x, y)

self.assertRaises(TypeError, test_x_dtype)

def test_y_dtype():
with fluid.program_guard(fluid.Program()):
x = fluid.data(name='x', shape=[10, 10], dtype='float64')
y = fluid.data(name='y', shape=[10, 10], dtype='int32')
with paddle.static.program_guard(paddle.static.Program(),
paddle.static.Program()):
x = paddle.data(name='x', shape=[10, 10], dtype='float64')
y = paddle.data(name='y', shape=[10, 10], dtype='int32')
result = paddle.allclose(x, y)

self.assertRaises(TypeError, test_y_dtype)

def test_attr(self):
x = fluid.data(name='x', shape=[10, 10], dtype='float64')
y = fluid.data(name='y', shape=[10, 10], dtype='float64')
x = paddle.data(name='x', shape=[10, 10], dtype='float64')
y = paddle.data(name='y', shape=[10, 10], dtype='float64')

def test_rtol():
result = paddle.allclose(x, y, rtol=True)
Expand Down

0 comments on commit 4916400

Please sign in to comment.