diff --git a/python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py b/python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py old mode 100644 new mode 100755 index f77fe90c4cee5f4e7ffd9159de73b08f74010529..385c18df77cbf1440928aac5428b7d3f6c4d37ee --- a/python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py +++ b/python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py @@ -486,25 +486,13 @@ class TestBilinearInterp_attr_tensor_Case3(TestBilinearInterpOp_attr_tensor): class TestBilinearInterpOpAPI(OpTest): def test_case(self): - x = fluid.layers.data(name="x", shape=[3, 6, 6], dtype="float32") - - dim = fluid.layers.data( - name="dim", shape=[1], dtype="int32", append_batch_size=False) - shape_tensor = fluid.layers.data( - name="shape_tensor", - shape=[2], - dtype="int32", - append_batch_size=False) - actual_size = fluid.layers.data( - name="actual_size", - shape=[2], - dtype="int32", - append_batch_size=False) - scale_tensor = fluid.layers.data( - name="scale_tensor", - shape=[1], - dtype="float32", - append_batch_size=False) + x = fluid.data(name="x", shape=[2, 3, 6, 6], dtype="float32") + + dim = fluid.data(name="dim", shape=[1], dtype="int32") + shape_tensor = fluid.data(name="shape_tensor", shape=[2], dtype="int32") + actual_size = fluid.data(name="actual_size", shape=[2], dtype="int32") + scale_tensor = fluid.data( + name="scale_tensor", shape=[1], dtype="float32") out1 = fluid.layers.resize_bilinear(x, out_shape=[12, 12]) out2 = fluid.layers.resize_bilinear(x, out_shape=[12, dim]) @@ -513,14 +501,18 @@ class TestBilinearInterpOpAPI(OpTest): x, out_shape=[4, 4], actual_shape=actual_size) out5 = fluid.layers.resize_bilinear(x, scale=scale_tensor) - x_data = np.random.random((1, 3, 6, 6)).astype("float32") + x_data = np.random.random((2, 3, 6, 6)).astype("float32") dim_data = np.array([12]).astype("int32") shape_data = np.array([12, 12]).astype("int32") actual_size_data = np.array([12, 12]).astype("int32") scale_data = np.array([2.0]).astype("float32") - place = core.CPUPlace() + if core.is_compiled_with_cuda(): + place = core.CUDAPlace(0) + else: + place = core.CPUPlace() exe = fluid.Executor(place) + exe.run(fluid.default_startup_program()) results = exe.run(fluid.default_main_program(), feed={ "x": x_data, diff --git a/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py b/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py index dbdca111da7064d0aca9f74c9d82966b6721e0ca..153a1073d0946438963413cccd430d8dc3908714 100755 --- a/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py +++ b/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py @@ -425,8 +425,8 @@ class TestNearestInterp_attr_tensor_Case3(TestNearestInterpOp_attr_tensor): class TestNearestAPI(OpTest): def test_case(self): - x = fluid.data(name="x", shape=[1, 3, 6, 6], dtype="float32") - y = fluid.data(name="y", shape=[1, 6, 6, 3], dtype="float32") + x = fluid.data(name="x", shape=[2, 3, 6, 6], dtype="float32") + y = fluid.data(name="y", shape=[2, 6, 6, 3], dtype="float32") dim = fluid.data(name="dim", shape=[1], dtype="int32") shape_tensor = fluid.data(name="shape_tensor", shape=[2], dtype="int32") @@ -442,14 +442,18 @@ class TestNearestAPI(OpTest): x, out_shape=[4, 4], actual_shape=actual_size) out5 = fluid.layers.resize_nearest(x, scale=scale_tensor) - x_data = np.random.random((1, 3, 6, 6)).astype("float32") + x_data = np.random.random((2, 3, 6, 6)).astype("float32") dim_data = np.array([12]).astype("int32") shape_data = np.array([12, 12]).astype("int32") actual_size_data = np.array([12, 12]).astype("int32") scale_data = np.array([2.0]).astype("float32") - place = core.CPUPlace() + if core.is_compiled_with_cuda(): + place = core.CUDAPlace(0) + else: + place = core.CPUPlace() exe = fluid.Executor(place) + exe.run(fluid.default_startup_program()) results = exe.run(fluid.default_main_program(), feed={ "x": x_data, diff --git a/python/paddle/fluid/tests/unittests/test_trilinear_interp_op.py b/python/paddle/fluid/tests/unittests/test_trilinear_interp_op.py index 899b4ba4341bd477093de4cbb71c6292eca7ffe1..9a0d1bb6bd34b47b5761ae9e12d2c915aaa56c40 100755 --- a/python/paddle/fluid/tests/unittests/test_trilinear_interp_op.py +++ b/python/paddle/fluid/tests/unittests/test_trilinear_interp_op.py @@ -570,25 +570,14 @@ class TestTrilinearInterp_attr_tensor_Case3(TestTrilinearInterpOp_attr_tensor): class TestTrilinearInterpAPI(OpTest): def test_case(self): - x = fluid.layers.data(name="x", shape=[3, 6, 9, 4], dtype="float32") - y = fluid.layers.data(name="y", shape=[6, 9, 4, 3], dtype="float32") - - dim = fluid.layers.data(name="dim", shape=[1], dtype="int32") - shape_tensor = fluid.layers.data( - name="shape_tensor", - shape=[3], - dtype="int32", - append_batch_size=False) - actual_size = fluid.layers.data( - name="actual_size", - shape=[3], - dtype="int32", - append_batch_size=False) - scale_tensor = fluid.layers.data( - name="scale_tensor", - shape=[1], - dtype="float32", - append_batch_size=False) + x = fluid.data(name="x", shape=[2, 3, 6, 9, 4], dtype="float32") + y = fluid.data(name="y", shape=[2, 6, 9, 4, 3], dtype="float32") + + dim = fluid.data(name="dim", shape=[1], dtype="int32") + shape_tensor = fluid.data(name="shape_tensor", shape=[3], dtype="int32") + actual_size = fluid.data(name="actual_size", shape=[3], dtype="int32") + scale_tensor = fluid.data( + name="scale_tensor", shape=[1], dtype="float32") out1 = fluid.layers.resize_trilinear( y, out_shape=[12, 18, 8], data_format='NDHWC') @@ -598,14 +587,18 @@ class TestTrilinearInterpAPI(OpTest): x, out_shape=[4, 4, 8], actual_shape=actual_size) out5 = fluid.layers.resize_trilinear(x, scale=scale_tensor) - x_data = np.random.random((1, 3, 6, 9, 4)).astype("float32") + x_data = np.random.random((2, 3, 6, 9, 4)).astype("float32") dim_data = np.array([18]).astype("int32") shape_data = np.array([12, 18, 8]).astype("int32") actual_size_data = np.array([12, 18, 8]).astype("int32") scale_data = np.array([2.0]).astype("float32") - place = core.CPUPlace() + if core.is_compiled_with_cuda(): + place = core.CUDAPlace(0) + else: + place = core.CPUPlace() exe = fluid.Executor(place) + exe.run(fluid.default_startup_program()) results = exe.run(fluid.default_main_program(), feed={ "x": x_data, @@ -628,8 +621,7 @@ class TestTrilinearInterpAPI(OpTest): class TestTrilinearInterpOpException(OpTest): def test_exception(self): - input = fluid.layers.data( - name="input", shape=[3, 6, 9, 4], dtype="float32") + input = fluid.data(name="input", shape=[2, 3, 6, 9, 4], dtype="float32") def attr_data_format(): # for 5-D input, data_format only can be NCDHW or NDHWC