From f188b3708e20ace99e7201b2fa1b7ee3b4ffa0d0 Mon Sep 17 00:00:00 2001 From: Zeng Jinle <32832641+sneaxiy@users.noreply.github.com> Date: Mon, 22 Apr 2019 10:56:22 -0500 Subject: [PATCH] Move gc test to each test of op (#16999) * move gc test to op_test test=develop * Revert "move gc test to op_test" This reverts commit cf15da65c38f57c91f53b3d8b3c2365d4aa86016. * enable gc test in some ops test=develop --- .../fluid/tests/unittests/CMakeLists.txt | 41 ++++++++++++++- ..._deletion_no_need_buffer_vars_inference.py | 51 ------------------- 2 files changed, 39 insertions(+), 53 deletions(-) delete mode 100644 python/paddle/fluid/tests/unittests/test_eager_deletion_no_need_buffer_vars_inference.py diff --git a/python/paddle/fluid/tests/unittests/CMakeLists.txt b/python/paddle/fluid/tests/unittests/CMakeLists.txt index ab3905821b..ca57de3e92 100644 --- a/python/paddle/fluid/tests/unittests/CMakeLists.txt +++ b/python/paddle/fluid/tests/unittests/CMakeLists.txt @@ -1,5 +1,6 @@ file(GLOB TEST_OPS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "test_*.py") string(REPLACE ".py" "" TEST_OPS "${TEST_OPS}") +set(GC_ENVS FLAGS_eager_delete_tensor_gb=0.0 FLAGS_fast_eager_deletion_mode=1 FLAGS_memory_fraction_of_eager_deletion=1.0) if(NOT WITH_DISTRIBUTE) list(REMOVE_ITEM TEST_OPS test_recv_op) @@ -80,13 +81,49 @@ list(REMOVE_ITEM TEST_OPS test_imperative_se_resnext) list(REMOVE_ITEM TEST_OPS test_imperative_mnist) list(REMOVE_ITEM TEST_OPS test_ir_memory_optimize_transformer) list(REMOVE_ITEM TEST_OPS test_layers) + +# Some ops need to check results when gc is enabled +# Currently, only ops that register NoNeedBufferVarsInference need to do this test +set(TEST_OPS_WITH_GC + test_concat_op + test_elementwise_add_op + test_elementwise_sub_op + test_fill_constant_batch_size_like_op + test_fill_zeros_like2_op + test_gather_op + test_gaussian_random_batch_size_like_op + test_linear_chain_crf_op + test_lod_reset_op + test_lookup_table_op + test_mean_op + test_pad2d_op + test_scatter_op + test_sequence_concat + test_seq_conv + test_seq_pool + test_sequence_expand_as + test_sequence_expand + test_sequence_pad_op + test_sequence_unpad_op + test_sequence_scatter_op + test_sequence_slice_op + test_slice_op + test_space_to_depth_op + test_squared_l2_distance_op + test_uniform_random_batch_size_like_op) + +foreach(TEST_OP ${TEST_OPS_WITH_GC}) + list(REMOVE_ITEM TEST_OPS ${TEST_OP}) + py_test_modules(${TEST_OP} MODULES ${TEST_OP} ENVS ${GC_ENVS}) +endforeach() + foreach(TEST_OP ${TEST_OPS}) py_test_modules(${TEST_OP} MODULES ${TEST_OP}) endforeach(TEST_OP) py_test_modules(test_adam_op_multi_thread MODULES test_adam_op ENVS FLAGS_inner_op_parallelism=4) py_test_modules(test_warpctc_op MODULES test_warpctc_op ENVS FLAGS_warpctc_dir=${WARPCTC_LIB_DIR} SERIAL) -py_test_modules(test_bilinear_interp_op MODULES test_bilinear_interp_op SERIAL) -py_test_modules(test_nearest_interp_op MODULES test_nearest_interp_op SERIAL) +py_test_modules(test_bilinear_interp_op MODULES test_bilinear_interp_op ENVS ${GC_ENVS} SERIAL) +py_test_modules(test_nearest_interp_op MODULES test_nearest_interp_op ENVS ${GC_ENVS} SERIAL) py_test_modules(test_imperative_resnet MODULES test_imperative_resnet ENVS FLAGS_cudnn_deterministic=1 SERIAL) py_test_modules(test_imperative_mnist MODULES test_imperative_mnist ENVS diff --git a/python/paddle/fluid/tests/unittests/test_eager_deletion_no_need_buffer_vars_inference.py b/python/paddle/fluid/tests/unittests/test_eager_deletion_no_need_buffer_vars_inference.py deleted file mode 100644 index 3fd582e4d5..0000000000 --- a/python/paddle/fluid/tests/unittests/test_eager_deletion_no_need_buffer_vars_inference.py +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright (c) 2019 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 unittest -import paddle.fluid as fluid -import importlib - -fluid.core._set_eager_deletion_mode(0.0, 1.0, True) - -from test_bilinear_interp_op import * -from test_concat_op import * -from test_elementwise_add_op import * -from test_elementwise_sub_op import * -from test_fill_constant_batch_size_like_op import * -from test_fill_zeros_like2_op import * -from test_gather_op import * -from test_gaussian_random_batch_size_like_op import * -from test_linear_chain_crf_op import * -from test_lod_reset_op import * -from test_lookup_table_op import * -from test_mean_op import * -from test_nearest_interp_op import * -from test_pad2d_op import * -from test_scatter_op import * -from test_sequence_concat import * -from test_seq_conv import * -from test_seq_pool import * -from test_sequence_expand_as import * -from test_sequence_expand import * -from test_sequence_pad_op import * -from test_sequence_unpad_op import * -from test_sequence_scatter_op import * -from test_sequence_slice_op import * -from test_slice_op import * -from test_space_to_depth_op import * -from test_squared_l2_distance_op import * -from test_uniform_random_batch_size_like_op import * - -if __name__ == '__main__': - unittest.main() -- GitLab