From 25a774502129214ebf0a8430b721476f494b8403 Mon Sep 17 00:00:00 2001 From: kangguangli Date: Wed, 8 Mar 2023 10:33:42 +0800 Subject: [PATCH] remove with_data_parallel in OpTest (#51237) --- .../fluid/tests/unittests/eager_op_test.py | 18 ++++-------------- python/paddle/fluid/tests/unittests/op_test.py | 18 ++++-------------- .../unittests/parallel_executor_test_base.py | 10 ++++------ .../test_multiprocess_dataloader_dynamic.py | 1 - ...cess_dataloader_iterable_dataset_dynamic.py | 1 - 5 files changed, 12 insertions(+), 36 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/eager_op_test.py b/python/paddle/fluid/tests/unittests/eager_op_test.py index cff3b34fdaf..d2e21863a87 100644 --- a/python/paddle/fluid/tests/unittests/eager_op_test.py +++ b/python/paddle/fluid/tests/unittests/eager_op_test.py @@ -943,11 +943,7 @@ class OpTest(unittest.TestCase): use_cuda = False if isinstance(place, fluid.CUDAPlace): use_cuda = True - compiled_prog = fluid.CompiledProgram( - program - ).with_data_parallel( - loss_name=loss.name if loss else None, places=place - ) + compiled_prog = fluid.CompiledProgram(program) program = compiled_prog fetch_list = getattr(self, "fetch_list", []) # if the fetch_list is customized by user, we use it directly. @@ -971,9 +967,7 @@ class OpTest(unittest.TestCase): build_strategy.enable_inplace = enable_inplace compiled_prog = fluid.CompiledProgram( - program - ).with_data_parallel( - build_strategy=build_strategy, places=place + program, build_strategy=build_strategy ) program = compiled_prog @@ -1273,9 +1267,7 @@ class OpTest(unittest.TestCase): build_strategy = fluid.BuildStrategy() build_strategy.enable_inplace = enable_inplace compiled_program = fluid.CompiledProgram( - grad_program - ).with_data_parallel( - loss_name="", build_strategy=build_strategy, places=place + grad_program, build_strategy=build_strategy ) program = compiled_program @@ -2426,9 +2418,7 @@ class OpTest(unittest.TestCase): use_cuda = False if isinstance(place, fluid.CUDAPlace): use_cuda = True - compiled_prog = fluid.CompiledProgram(prog).with_data_parallel( - loss_name=loss.name, places=place - ) + compiled_prog = fluid.CompiledProgram(prog) prog = compiled_prog executor = fluid.Executor(place) res = list( diff --git a/python/paddle/fluid/tests/unittests/op_test.py b/python/paddle/fluid/tests/unittests/op_test.py index d5bfbce28a7..d9c4cfce2a8 100644 --- a/python/paddle/fluid/tests/unittests/op_test.py +++ b/python/paddle/fluid/tests/unittests/op_test.py @@ -1041,11 +1041,7 @@ class OpTest(unittest.TestCase): use_cuda = False if isinstance(place, fluid.CUDAPlace): use_cuda = True - compiled_prog = fluid.CompiledProgram( - program - ).with_data_parallel( - loss_name=loss.name if loss else None, places=place - ) + compiled_prog = fluid.CompiledProgram(program) program = compiled_prog fetch_list = getattr(self, "fetch_list", []) # if the fetch_list is customized by user, we use it directly. @@ -1069,9 +1065,7 @@ class OpTest(unittest.TestCase): build_strategy.enable_inplace = enable_inplace compiled_prog = fluid.CompiledProgram( - program - ).with_data_parallel( - build_strategy=build_strategy, places=place + program, build_strategy=build_strategy ) program = compiled_prog @@ -1371,9 +1365,7 @@ class OpTest(unittest.TestCase): build_strategy = fluid.BuildStrategy() build_strategy.enable_inplace = enable_inplace compiled_program = fluid.CompiledProgram( - grad_program - ).with_data_parallel( - loss_name="", build_strategy=build_strategy, places=place + grad_program, build_strategy=build_strategy ) program = compiled_program @@ -2736,9 +2728,7 @@ class OpTest(unittest.TestCase): use_cuda = False if isinstance(place, fluid.CUDAPlace): use_cuda = True - compiled_prog = fluid.CompiledProgram(prog).with_data_parallel( - loss_name=loss.name, places=place - ) + compiled_prog = fluid.CompiledProgram(prog) prog = compiled_prog executor = fluid.Executor(place) res = list( diff --git a/python/paddle/fluid/tests/unittests/parallel_executor_test_base.py b/python/paddle/fluid/tests/unittests/parallel_executor_test_base.py index 5ff55155ccd..6096300e5ef 100644 --- a/python/paddle/fluid/tests/unittests/parallel_executor_test_base.py +++ b/python/paddle/fluid/tests/unittests/parallel_executor_test_base.py @@ -104,10 +104,9 @@ class TestParallelExecutorBase(unittest.TestCase): ) if use_parallel_executor: - binary = compiler.CompiledProgram(main).with_data_parallel( - loss_name=loss.name, + binary = compiler.CompiledProgram( + main, build_strategy=build_strategy, - exec_strategy=exec_strategy, ) else: binary = main @@ -204,10 +203,9 @@ class TestParallelExecutorBase(unittest.TestCase): use_device, ) - binary = compiler.CompiledProgram(main).with_data_parallel( - loss_name=loss.name, + binary = compiler.CompiledProgram( + main, build_strategy=build_strategy, - exec_strategy=exec_strategy, ) exe.run(binary, feed=feed_dict, fetch_list=[loss.name]) diff --git a/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_dynamic.py b/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_dynamic.py index 2fc0f8ac175..03af43716a5 100644 --- a/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_dynamic.py +++ b/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_dynamic.py @@ -121,7 +121,6 @@ class TestDygraphDataLoader(unittest.TestCase): return ret def test_main(self): - # dynamic graph do not run with_data_parallel for p in prepare_places(): for persistent_workers in [False, True]: results = [] diff --git a/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_iterable_dataset_dynamic.py b/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_iterable_dataset_dynamic.py index 3c5b7fa5b3d..e0140621d07 100644 --- a/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_iterable_dataset_dynamic.py +++ b/python/paddle/fluid/tests/unittests/test_multiprocess_dataloader_iterable_dataset_dynamic.py @@ -121,7 +121,6 @@ class TestDygraphDataLoader(unittest.TestCase): return ret def test_main(self): - # dynamic graph do not run with_data_parallel for p in prepare_places(): for persistent_workers in [False, True]: results = [] -- GitLab