未验证 提交 9af23f1d 编写于 作者: K kangguangli 提交者: GitHub

remove test_fetch_unmerged (#50619)

上级 3c7e94d6
......@@ -890,7 +890,6 @@ set_tests_properties(
test_dataloader_keep_order
test_dataloader_unkeep_order
test_parallel_ssa_graph_inference_feed_partial_data
test_fetch_unmerged
test_buffer_shared_memory_reuse_pass
PROPERTIES LABELS "RUN_TYPE=DIST")
set_tests_properties(
......@@ -968,7 +967,6 @@ set_tests_properties(test_inplace_softmax_with_cross_entropy PROPERTIES TIMEOUT
120)
set_tests_properties(test_cross_entropy2_op PROPERTIES TIMEOUT 120)
set_tests_properties(test_cross_entropy_loss PROPERTIES TIMEOUT 180)
set_tests_properties(test_fetch_unmerged PROPERTIES TIMEOUT 120)
set_tests_properties(test_gru_unit_op PROPERTIES TIMEOUT 120)
set_tests_properties(test_activation_nn_grad PROPERTIES TIMEOUT 200)
set_tests_properties(test_empty_op PROPERTIES TIMEOUT 120)
......
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import unittest
import numpy as np
import paddle
import paddle.fluid as fluid
os.environ["CPU_NUM"] = "2"
class TestFetchUnmerged(unittest.TestCase):
def conv_net(self, img, label):
conv_pool_1 = fluid.nets.simple_img_conv_pool(
input=img,
filter_size=5,
num_filters=8,
pool_size=2,
pool_stride=2,
pool_type='max',
act="relu",
)
conv_pool_1 = paddle.static.nn.batch_norm(conv_pool_1)
conv_pool_2 = fluid.nets.simple_img_conv_pool(
input=conv_pool_1,
filter_size=5,
num_filters=16,
pool_size=2,
pool_stride=2,
pool_type='avg',
act="relu",
)
hidden = paddle.static.nn.fc(x=conv_pool_2, size=32, activation='relu')
prediction = paddle.static.nn.fc(
x=hidden, size=10, activation='softmax'
)
loss = paddle.nn.functional.cross_entropy(
input=prediction, label=label, reduction='none', use_softmax=False
)
avg_loss = paddle.mean(loss)
return avg_loss, prediction
def build_program(self, main, startup, is_test):
with fluid.unique_name.guard():
with fluid.program_guard(main, startup):
img = paddle.static.data(
name='image', shape=[-1, 1, 28, 28], dtype='float32'
)
label = paddle.static.data(
name='label', shape=[-1, 1], dtype='int64'
)
loss, prediction = self.conv_net(img, label)
if not is_test:
opt = fluid.optimizer.Adam(learning_rate=0.001)
opt.minimize(loss)
return [img, label], loss, prediction
def fetch_unmerged(self, use_cuda=True):
main_program = fluid.Program()
startup_program = fluid.Program()
feeds, loss, prediction = self.build_program(
main_program, startup_program, False
)
place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()
exe = fluid.Executor(place)
exe.run(startup_program)
build_strategy = fluid.BuildStrategy()
binary = fluid.CompiledProgram(main_program).with_data_parallel(
loss_name=loss.name, build_strategy=build_strategy
)
iters = 2
batch_size = 16
train_reader = paddle.batch(
paddle.reader.shuffle(paddle.dataset.mnist.train(), buf_size=500),
batch_size=batch_size,
)
feeder = fluid.DataFeeder(feed_list=feeds, place=place)
device_num = fluid.core.get_cuda_device_count() if use_cuda else 2
for _ in range(iters):
data = next(train_reader())
loss_v, prediction_v = exe.run(
binary,
feed=feeder.feed(data),
fetch_list=[loss, prediction],
return_merged=False,
)
self.assertEqual(np.array(loss_v).shape, (device_num, 1))
self.assertEqual(
np.array(prediction_v).shape,
(device_num, batch_size / device_num, 10),
)
for _ in range(iters):
data = next(train_reader())
loss_v, prediction_v = exe.run(
binary,
feed=feeder.feed(data),
fetch_list=[loss, prediction],
return_merged=True,
)
self.assertEqual(np.array(loss_v).shape, (device_num,))
self.assertEqual(np.array(prediction_v).shape, (batch_size, 10))
def test_fetch_unmerged(self):
if fluid.core.is_compiled_with_cuda():
self.fetch_unmerged(use_cuda=True)
self.fetch_unmerged(use_cuda=False)
def test_fetch_unmerged_parallel_graph(self):
fluid.core.globals()['FLAGS_enable_parallel_graph'] = True
if fluid.core.is_compiled_with_cuda():
self.fetch_unmerged(use_cuda=True)
self.fetch_unmerged(use_cuda=False)
fluid.core.globals()['FLAGS_enable_parallel_graph'] = False
if __name__ == '__main__':
unittest.main()
......@@ -1506,7 +1506,6 @@ FOURTH_HIGH_PARALLEL_JOB_NEW = [
'test_smooth_l1_loss',
'test_bilateral_slice_op',
'test_inplace_abn_op',
'test_fetch_unmerged',
'test_parallel_executor_seresnext_base_gpu',
'test_parallel_executor_seresnext_with_fuse_all_reduce_gpu',
'test_parallel_ssa_graph_inference_feed_partial_data',
......@@ -2336,7 +2335,6 @@ TETRAD_PARALLEL_JOB = [
'test_tensorrt_engine',
'test_load_state_dict_from_old_format',
'test_fuse_elewise_add_act_pass',
'test_fetch_unmerged',
'test_randint_op',
'test_standalone_controlflow',
'test_standalone_multiply_write',
......
......@@ -197,7 +197,6 @@ STATIC_MODE_TESTING_LIST = [
'test_fc_op',
'test_feed_data_check_shape_type',
'test_fetch_lod_tensor_array',
'test_fetch_unmerged',
'test_fetch_var',
'test_fill_any_like_op',
'test_fill_constant_op',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册