From 9af23f1d3cc9755c54efb5b982380837a6da695c Mon Sep 17 00:00:00 2001 From: kangguangli Date: Tue, 21 Feb 2023 20:50:42 +0800 Subject: [PATCH] remove test_fetch_unmerged (#50619) --- .../fluid/tests/unittests/CMakeLists.txt | 2 - .../tests/unittests/test_fetch_unmerged.py | 136 ------------------ tools/parallel_UT_rule.py | 2 - tools/static_mode_white_list.py | 1 - 4 files changed, 141 deletions(-) delete mode 100644 python/paddle/fluid/tests/unittests/test_fetch_unmerged.py diff --git a/python/paddle/fluid/tests/unittests/CMakeLists.txt b/python/paddle/fluid/tests/unittests/CMakeLists.txt index 61bdf762591..e7c83de419b 100755 --- a/python/paddle/fluid/tests/unittests/CMakeLists.txt +++ b/python/paddle/fluid/tests/unittests/CMakeLists.txt @@ -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) diff --git a/python/paddle/fluid/tests/unittests/test_fetch_unmerged.py b/python/paddle/fluid/tests/unittests/test_fetch_unmerged.py deleted file mode 100644 index f7313f93e0d..00000000000 --- a/python/paddle/fluid/tests/unittests/test_fetch_unmerged.py +++ /dev/null @@ -1,136 +0,0 @@ -# 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() diff --git a/tools/parallel_UT_rule.py b/tools/parallel_UT_rule.py index 3b6d7b8c050..29a4ce26a5b 100755 --- a/tools/parallel_UT_rule.py +++ b/tools/parallel_UT_rule.py @@ -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', diff --git a/tools/static_mode_white_list.py b/tools/static_mode_white_list.py index 6524c2a6e8c..5edb12a6d45 100755 --- a/tools/static_mode_white_list.py +++ b/tools/static_mode_white_list.py @@ -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', -- GitLab