Skip to content

Commit 97cb74e

Browse files
committed
fix flatten infershape; test=develop
1 parent 8381047 commit 97cb74e

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

python/paddle/fluid/tests/unittests/test_flatten2_op.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,17 +76,12 @@ def execute_api(self, x, axis=1):
7676

7777
def test_static_api(self):
7878
paddle.enable_static()
79-
np_x = np.random.rand(2, 3, 4, 4).astype('float32')
80-
8179
main_prog = paddle.static.Program()
8280
with paddle.static.program_guard(main_prog, paddle.static.Program()):
8381
x = paddle.static.data(
8482
name="x", shape=[-1, 3, -1, -1], dtype='float32')
8583
out = self.execute_api(x, axis=2)
86-
87-
exe = paddle.static.Executor(place=paddle.CPUPlace())
88-
fetch_out = exe.run(main_prog, feed={"x": np_x}, fetch_list=[out])
89-
self.assertTrue((6, 16) == fetch_out[0].shape)
84+
self.assertTrue((-1, -1) == out.shape)
9085

9186

9287
class TestFlatten2OpError(unittest.TestCase):

python/paddle/fluid/tests/unittests/test_flatten_contiguous_range_op.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,17 +207,12 @@ def execute_api(self, x, start_axis=0, stop_axis=-1):
207207

208208
def test_static_api(self):
209209
paddle.enable_static()
210-
np_x = np.random.rand(2, 3, 4, 4).astype('float32')
211-
212210
main_prog = paddle.static.Program()
213211
with paddle.static.program_guard(main_prog, paddle.static.Program()):
214212
x = paddle.static.data(
215213
name="x", shape=[-1, 3, -1, -1], dtype='float32')
216214
out = self.execute_api(x, start_axis=2, stop_axis=3)
217-
218-
exe = paddle.static.Executor(place=paddle.CPUPlace())
219-
fetch_out = exe.run(main_prog, feed={"x": np_x}, fetch_list=[out])
220-
self.assertTrue((2, 3, 16) == fetch_out[0].shape)
215+
self.assertTrue((-1, 3, -1) == out.shape)
221216

222217

223218
class TestStaticInplaceFlattenPythonAPI(TestStaticFlattenPythonAPI):

0 commit comments

Comments
 (0)