Skip to content

Commit 2466ca1

Browse files
authored
test(Pe): remove unittests for recordio in test_pe_mnist (#14262)
recordio is not the official API in Fluid 1.0. Remove unittests for it. test=develop
1 parent 0399263 commit 2466ca1

File tree

1 file changed

+9
-52
lines changed

1 file changed

+9
-52
lines changed

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

Lines changed: 9 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,18 @@
1414

1515
from __future__ import print_function
1616

17-
from parallel_executor_test_base import TestParallelExecutorBase
18-
import paddle.fluid as fluid
19-
import paddle.fluid.core as core
20-
import numpy as np
21-
import paddle
22-
import paddle.dataset.mnist as mnist
2317
import unittest
24-
import os
2518

26-
MNIST_RECORDIO_FILE = "./mnist_test_pe.recordio"
19+
import numpy as np
20+
import paddle.fluid.core as core
21+
import os
22+
import paddle.fluid as fluid
23+
from parallel_executor_test_base import TestParallelExecutorBase
2724

2825

2926
def simple_fc_net(use_feed):
30-
if use_feed:
31-
img = fluid.layers.data(name='image', shape=[784], dtype='float32')
32-
label = fluid.layers.data(name='label', shape=[1], dtype='int64')
33-
else:
34-
reader = fluid.layers.open_files(
35-
filenames=[MNIST_RECORDIO_FILE],
36-
shapes=[[-1, 784], [-1, 1]],
37-
lod_levels=[0, 0],
38-
dtypes=['float32', 'int64'])
39-
reader = fluid.layers.io.double_buffer(reader)
40-
img, label = fluid.layers.read_file(reader)
27+
img = fluid.layers.data(name='image', shape=[784], dtype='float32')
28+
label = fluid.layers.data(name='label', shape=[1], dtype='int64')
4129
hidden = img
4230
for _ in range(4):
4331
hidden = fluid.layers.fc(
@@ -53,17 +41,8 @@ def simple_fc_net(use_feed):
5341

5442

5543
def fc_with_batchnorm(use_feed):
56-
if use_feed:
57-
img = fluid.layers.data(name='image', shape=[784], dtype='float32')
58-
label = fluid.layers.data(name='label', shape=[1], dtype='int64')
59-
else:
60-
reader = fluid.layers.open_files(
61-
filenames=[MNIST_RECORDIO_FILE],
62-
shapes=[[-1, 784], [-1, 1]],
63-
lod_levels=[0, 0],
64-
dtypes=['float32', 'int64'])
65-
reader = fluid.layers.io.double_buffer(reader)
66-
img, label = fluid.layers.read_file(reader)
44+
img = fluid.layers.data(name='image', shape=[784], dtype='float32')
45+
label = fluid.layers.data(name='label', shape=[1], dtype='int64')
6746

6847
hidden = img
6948
for _ in range(1):
@@ -88,19 +67,6 @@ class TestMNIST(TestParallelExecutorBase):
8867
@classmethod
8968
def setUpClass(cls):
9069
os.environ['CPU_NUM'] = str(4)
91-
# Convert mnist to recordio file
92-
with fluid.program_guard(fluid.Program(), fluid.Program()):
93-
reader = paddle.batch(mnist.train(), batch_size=4)
94-
feeder = fluid.DataFeeder(
95-
feed_list=[ # order is image and label
96-
fluid.layers.data(
97-
name='image', shape=[784]),
98-
fluid.layers.data(
99-
name='label', shape=[1], dtype='int64'),
100-
],
101-
place=fluid.CPUPlace())
102-
fluid.recordio_writer.convert_reader_to_recordio_file(
103-
MNIST_RECORDIO_FILE, reader, feeder)
10470

10571
def _init_data(self):
10672
np.random.seed(5)
@@ -111,10 +77,6 @@ def _init_data(self):
11177
def _compare_reduce_and_allreduce(self, model, use_cuda):
11278
if use_cuda and not core.is_compiled_with_cuda():
11379
return
114-
self.check_network_convergence(
115-
model, use_cuda=use_cuda, use_reduce=True)
116-
self.check_network_convergence(
117-
model, use_cuda=use_cuda, allow_op_delay=True, use_reduce=True)
11880

11981
img, label = self._init_data()
12082

@@ -140,9 +102,6 @@ def _compare_reduce_and_allreduce(self, model, use_cuda):
140102
def check_simple_fc_convergence(self, use_cuda, use_reduce=False):
141103
if use_cuda and not core.is_compiled_with_cuda():
142104
return
143-
self.check_network_convergence(simple_fc_net, use_cuda=use_cuda)
144-
self.check_network_convergence(
145-
simple_fc_net, use_cuda=use_cuda, allow_op_delay=True)
146105

147106
img, label = self._init_data()
148107

@@ -199,8 +158,6 @@ def check_batchnorm_fc_convergence(self, use_cuda, use_fast_executor):
199158
if use_cuda and not core.is_compiled_with_cuda():
200159
return
201160

202-
self.check_network_convergence(fc_with_batchnorm, use_cuda=use_cuda)
203-
204161
img, label = self._init_data()
205162

206163
self.check_network_convergence(

0 commit comments

Comments
 (0)