def test_api_case(self):
     paddle.enable_static()
     x_data = np.random.rand(10, 10)
     y_data = np.random.rand(10, 10)
     places = [paddle.fluid.CPUPlace()]
     if paddle.fluid.core.is_compiled_with_cuda():
         places.append(paddle.fluid.CUDAPlace(0))
     for place in places:
         with paddle.static.program_guard(paddle.static.Program(),
                                          paddle.static.Program()):
             x = paddle.fluid.data(name='x',
                                   shape=[10, 10],
                                   dtype='float64')
             y = paddle.fluid.data(name='y',
                                   shape=[10, 10],
                                   dtype='float64')
             result = paddle.isclose(x, y)
             exe = paddle.fluid.Executor(place)
             fetches = exe.run(paddle.fluid.default_main_program(),
                               feed={
                                   "x": x_data,
                                   "y": y_data
                               },
                               fetch_list=[result])
             expected_out = np.isclose(x_data, y_data)
             self.assertTrue((fetches[0] == expected_out).all(), True)
 def test_y_dtype():
     with paddle.static.program_guard(paddle.static.Program(),
                                      paddle.static.Program()):
         x = paddle.fluid.data(name='x',
                               shape=[10, 10],
                               dtype='float64')
         y = paddle.fluid.data(name='y', shape=[10, 10], dtype='int32')
         result = paddle.isclose(x, y)
Beispiel #3
0
 def test_api_case(self):
     places = [paddle.CPUPlace()]
     if paddle.fluid.core.is_compiled_with_cuda():
         places.append(paddle.CUDAPlace(0))
     for place in places:
         paddle.disable_static()
         x_data = np.random.rand(10, 10)
         y_data = np.random.rand(10, 10)
         x = paddle.to_tensor(x_data, place=place)
         y = paddle.to_tensor(y_data, place=place)
         out = paddle.isclose(x, y, rtol=1e-05, atol=1e-08)
         expected_out = np.isclose(x_data, y_data, rtol=1e-05, atol=1e-08)
         self.assertTrue((out.numpy() == expected_out).all(), True)
     paddle.enable_static()
Beispiel #4
0
 def test_equal_nan():
     result = paddle.isclose(x, y, equal_nan=1)
Beispiel #5
0
 def test_atol():
     result = paddle.isclose(x, y, rtol=True)