From cf15da65c38f57c91f53b3d8b3c2365d4aa86016 Mon Sep 17 00:00:00 2001 From: sneaxiy Date: Sun, 21 Apr 2019 04:27:11 +0000 Subject: [PATCH] move gc test to op_test test=develop --- .../paddle/fluid/tests/unittests/op_test.py | 54 +++++++++++++++++++ .../unittests/test_bilinear_interp_op.py | 2 + .../fluid/tests/unittests/test_concat_op.py | 1 + ..._deletion_no_need_buffer_vars_inference.py | 51 ------------------ .../unittests/test_elementwise_add_op.py | 1 + .../unittests/test_elementwise_sub_op.py | 1 + .../test_fill_constant_batch_size_like_op.py | 3 ++ .../unittests/test_fill_zeros_like2_op.py | 1 + .../fluid/tests/unittests/test_gather_op.py | 1 + ...test_gaussian_random_batch_size_like_op.py | 1 + .../unittests/test_linear_chain_crf_op.py | 1 + .../tests/unittests/test_lod_reset_op.py | 4 ++ .../tests/unittests/test_lookup_table_op.py | 2 + .../fluid/tests/unittests/test_mean_op.py | 1 + .../tests/unittests/test_nearest_interp_op.py | 2 + .../fluid/tests/unittests/test_pad2d_op.py | 1 + .../fluid/tests/unittests/test_scatter_op.py | 1 + .../fluid/tests/unittests/test_seq_conv.py | 1 + .../fluid/tests/unittests/test_seq_pool.py | 1 + .../tests/unittests/test_sequence_concat.py | 1 + .../tests/unittests/test_sequence_expand.py | 1 + .../unittests/test_sequence_expand_as.py | 1 + .../tests/unittests/test_sequence_pad_op.py | 1 + .../unittests/test_sequence_scatter_op.py | 1 + .../tests/unittests/test_sequence_slice_op.py | 1 + .../tests/unittests/test_sequence_unpad_op.py | 1 + .../fluid/tests/unittests/test_slice_op.py | 1 + .../tests/unittests/test_space_to_depth_op.py | 1 + .../unittests/test_squared_l2_distance_op.py | 3 ++ .../test_uniform_random_batch_size_like_op.py | 1 + 30 files changed, 92 insertions(+), 51 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/op_test.py b/python/paddle/fluid/tests/unittests/op_test.py index 6b8622b6f26..6079de951fc 100644 --- a/python/paddle/fluid/tests/unittests/op_test.py +++ b/python/paddle/fluid/tests/unittests/op_test.py @@ -371,6 +371,20 @@ class OpTest(unittest.TestCase): no_check_set=None, equal_nan=False, check_dygraph=False): + self._check_output_with_place(place, atol, no_check_set, equal_nan, + check_dygraph) + if self._is_gc_test_enabled(): + self._enable_gc(True) + self._check_output_with_place(place, atol, no_check_set, equal_nan, + check_dygraph) + self._enable_gc(False) + + def _check_output_with_place(self, + place, + atol, + no_check_set=None, + equal_nan=False, + check_dygraph=False): if check_dygraph: dygraph_outs = self._calc_dygraph_output( place, no_check_set=no_check_set) @@ -492,6 +506,19 @@ class OpTest(unittest.TestCase): places.append(core.CUDAPlace(0)) return places + def _is_gc_test_enabled(self): + if hasattr(self, "test_gc") and self.test_gc: + # FIXME(zjl): if ngraph is enabled, some ops would be fused in Executor + # This may cause error of gc. Disable unittests of gc when FLAGS_use_ngraph is True + is_ngraph_enabled = bool(os.environ.get('FLAGS_use_ngraph', False)) + return False if is_ngraph_enabled else True + else: + return False + + def _enable_gc(self, enabled): + threshold = 0.0 if enabled else -1.0 + fluid.core._set_eager_deletion_mode(threshold, 1.0, True) + def check_output(self, atol=1e-5, no_check_set=None, @@ -503,6 +530,13 @@ class OpTest(unittest.TestCase): check_dygraph) def check_output_customized(self, checker): + self._check_output_customized(checker) + if self._is_gc_test_enabled(): + self._enable_gc(True) + self._check_output_customized(checker) + self._enable_gc(False) + + def _check_output_customized(self, checker): places = self._get_places() for place in places: outs = self.calc_output(place) @@ -553,6 +587,26 @@ class OpTest(unittest.TestCase): in_place=False, max_relative_error=0.005, user_defined_grads=None): + self._check_grad_with_place(place, inputs_to_check, output_names, + no_grad_set, numeric_grad_delta, in_place, + max_relative_error, user_defined_grads) + if self._is_gc_test_enabled(): + self._enable_gc(True) + self._check_grad_with_place(place, inputs_to_check, output_names, + no_grad_set, numeric_grad_delta, + in_place, max_relative_error, + user_defined_grads) + self._enable_gc(False) + + def _check_grad_with_place(self, + place, + inputs_to_check, + output_names, + no_grad_set=None, + numeric_grad_delta=0.005, + in_place=False, + max_relative_error=0.005, + user_defined_grads=None): self.scope = core.Scope() op_inputs = self.inputs if hasattr(self, "inputs") else dict() op_outputs = self.outputs if hasattr(self, "outputs") else dict() diff --git a/python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py b/python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py index 963a17e7d69..4dab62edee7 100644 --- a/python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py +++ b/python/paddle/fluid/tests/unittests/test_bilinear_interp_op.py @@ -85,6 +85,7 @@ def bilinear_interp_np(input, class TestBilinearInterpOp(OpTest): def setUp(self): + self.test_gc = True self.out_size = None self.actual_shape = None self.init_test_case() @@ -217,6 +218,7 @@ class TestBilinearInterpActualShape(TestBilinearInterpOp): class TestBilinearInterpOpUint8(OpTest): def setUp(self): + self.test_gc = True self.out_size = None self.actual_shape = None self.init_test_case() diff --git a/python/paddle/fluid/tests/unittests/test_concat_op.py b/python/paddle/fluid/tests/unittests/test_concat_op.py index 436ab7d49f4..44f3074dee1 100644 --- a/python/paddle/fluid/tests/unittests/test_concat_op.py +++ b/python/paddle/fluid/tests/unittests/test_concat_op.py @@ -21,6 +21,7 @@ from op_test import OpTest class TestConcatOp(OpTest): def setUp(self): + self.test_gc = True self.op_type = "concat" self.init_test_data() self.inputs = {'X': [('x0', self.x0), ('x1', self.x1), ('x2', self.x2)]} 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 3fd582e4d5c..00000000000 --- 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() diff --git a/python/paddle/fluid/tests/unittests/test_elementwise_add_op.py b/python/paddle/fluid/tests/unittests/test_elementwise_add_op.py index 5aec5d8e38a..5d85a2d9eed 100644 --- a/python/paddle/fluid/tests/unittests/test_elementwise_add_op.py +++ b/python/paddle/fluid/tests/unittests/test_elementwise_add_op.py @@ -24,6 +24,7 @@ class TestElementwiseAddOp(OpTest): self.use_mkldnn = False def setUp(self): + self.test_gc = True self.op_type = "elementwise_add" self.dtype = np.float32 self.axis = -1 diff --git a/python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py b/python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py index 6cb88a8bb1c..a3dc42667ab 100644 --- a/python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py +++ b/python/paddle/fluid/tests/unittests/test_elementwise_sub_op.py @@ -20,6 +20,7 @@ from op_test import OpTest class TestElementwiseOp(OpTest): def setUp(self): + self.test_gc = True self.op_type = "elementwise_sub" self.inputs = { 'X': np.random.uniform(0.1, 1, [2, 3]).astype("float32"), diff --git a/python/paddle/fluid/tests/unittests/test_fill_constant_batch_size_like_op.py b/python/paddle/fluid/tests/unittests/test_fill_constant_batch_size_like_op.py index fdc8a118e56..37a4a728952 100644 --- a/python/paddle/fluid/tests/unittests/test_fill_constant_batch_size_like_op.py +++ b/python/paddle/fluid/tests/unittests/test_fill_constant_batch_size_like_op.py @@ -21,6 +21,7 @@ from op_test import OpTest class TestFillConstantBatchSizeLikeWhenFirstDimIsBatchSize(OpTest): def setUp(self): + self.test_gc = True self.op_type = "fill_constant_batch_size_like" self.inputs = {'Input': np.random.random((219, 232)).astype("float32")} self.attrs = {'value': 3.5, 'shape': [-1, 132, 7]} @@ -35,6 +36,7 @@ class TestFillConstantBatchSizeLikeWhenFirstDimIsBatchSize(OpTest): class TestFillConstantBatchSizeLikeWhenSecondDimIsBatchSize(OpTest): def setUp(self): + self.test_gc = True self.op_type = "fill_constant_batch_size_like" self.inputs = {'Input': np.random.random((219, 232)).astype("float32")} self.attrs = { @@ -54,6 +56,7 @@ class TestFillConstantBatchSizeLikeWhenSecondDimIsBatchSize(OpTest): class TestFillConstantBatchSizeLikeWithLoDTensor(OpTest): def setUp(self): + self.test_gc = True self.op_type = "fill_constant_batch_size_like" self.inputs = { 'Input': (np.random.random((31, 28)).astype("float32"), diff --git a/python/paddle/fluid/tests/unittests/test_fill_zeros_like2_op.py b/python/paddle/fluid/tests/unittests/test_fill_zeros_like2_op.py index 935653b07a6..e1f11a15b01 100644 --- a/python/paddle/fluid/tests/unittests/test_fill_zeros_like2_op.py +++ b/python/paddle/fluid/tests/unittests/test_fill_zeros_like2_op.py @@ -22,6 +22,7 @@ from op_test import OpTest class TestFillZerosLike2Op(OpTest): def setUp(self): + self.test_gc = True self.op_type = "fill_zeros_like2" self.dtype = np.float32 self.init_dtype() diff --git a/python/paddle/fluid/tests/unittests/test_gather_op.py b/python/paddle/fluid/tests/unittests/test_gather_op.py index bd5785aa55a..aa068459ae3 100644 --- a/python/paddle/fluid/tests/unittests/test_gather_op.py +++ b/python/paddle/fluid/tests/unittests/test_gather_op.py @@ -21,6 +21,7 @@ from op_test import OpTest class TestGatherOp(OpTest): def setUp(self): + self.test_gc = True self.op_type = "gather" self.config() xnp = np.random.random(self.x_shape).astype("float32") diff --git a/python/paddle/fluid/tests/unittests/test_gaussian_random_batch_size_like_op.py b/python/paddle/fluid/tests/unittests/test_gaussian_random_batch_size_like_op.py index 9a0631fa26a..6f760c5a1a5 100644 --- a/python/paddle/fluid/tests/unittests/test_gaussian_random_batch_size_like_op.py +++ b/python/paddle/fluid/tests/unittests/test_gaussian_random_batch_size_like_op.py @@ -21,6 +21,7 @@ from op_test import OpTest class TestGaussianRandomBatchSizeLike(OpTest): def setUp(self): + self.test_gc = True self.op_type = "gaussian_random_batch_size_like" self.inputs = {'Input': np.zeros((500, 2000), dtype="float32")} self.attrs = {'mean': 1., 'std': 2., 'shape': [-1, 2000]} diff --git a/python/paddle/fluid/tests/unittests/test_linear_chain_crf_op.py b/python/paddle/fluid/tests/unittests/test_linear_chain_crf_op.py index b365e1642ef..ef8433cef70 100644 --- a/python/paddle/fluid/tests/unittests/test_linear_chain_crf_op.py +++ b/python/paddle/fluid/tests/unittests/test_linear_chain_crf_op.py @@ -143,6 +143,7 @@ class TestLinearChainCrfOp(OpTest): } def setUp(self): + self.test_gc = True self.op_type = "linear_chain_crf" self.set_test_data() diff --git a/python/paddle/fluid/tests/unittests/test_lod_reset_op.py b/python/paddle/fluid/tests/unittests/test_lod_reset_op.py index 31f364a42f6..74c407156f3 100644 --- a/python/paddle/fluid/tests/unittests/test_lod_reset_op.py +++ b/python/paddle/fluid/tests/unittests/test_lod_reset_op.py @@ -21,6 +21,7 @@ from op_test import OpTest class TestLodResetOpByAttr(OpTest): def setUp(self): + self.test_gc = True self.op_type = "lod_reset" x = np.random.random((10, 20)).astype("float32") lod = [[3, 2, 5]] @@ -42,6 +43,7 @@ class TestLodResetOpByAttr(OpTest): class TestLodResetOpByInput(OpTest): def setUp(self): + self.test_gc = True self.op_type = "lod_reset" x = np.random.random((10, 20)).astype("float32") lod = [[3, 2, 5]] @@ -64,6 +66,7 @@ class TestLodResetOpByInput(OpTest): class TestLodResetOpBoth(OpTest): def setUp(self): + self.test_gc = True self.op_type = "lod_reset" x = np.random.random((10, 20)).astype("float32") lod = [[3, 2, 5]] @@ -86,6 +89,7 @@ class TestLodResetOpBoth(OpTest): class TestLodResetOpYIsLoDTensor(OpTest): def setUp(self): + self.test_gc = True self.op_type = "lod_reset" x = np.random.random((10, 20)).astype("float32") lod = [[3, 2, 5]] diff --git a/python/paddle/fluid/tests/unittests/test_lookup_table_op.py b/python/paddle/fluid/tests/unittests/test_lookup_table_op.py index 4990ee898d8..388afe58227 100644 --- a/python/paddle/fluid/tests/unittests/test_lookup_table_op.py +++ b/python/paddle/fluid/tests/unittests/test_lookup_table_op.py @@ -24,6 +24,7 @@ import paddle.compat as cpt class TestLookupTableOp(OpTest): def setUp(self): + self.test_gc = True self.op_type = "lookup_table" table = np.random.random((17, 31)).astype("float32") ids = np.random.randint(0, 17, 4).astype("int64") @@ -40,6 +41,7 @@ class TestLookupTableOp(OpTest): class TestLookupTableOpWithTensorIds(OpTest): def setUp(self): + self.test_gc = True self.op_type = "lookup_table" table = np.random.random((17, 31)).astype("float32") ids = np.random.randint( diff --git a/python/paddle/fluid/tests/unittests/test_mean_op.py b/python/paddle/fluid/tests/unittests/test_mean_op.py index beae909e9b4..fb53235166a 100644 --- a/python/paddle/fluid/tests/unittests/test_mean_op.py +++ b/python/paddle/fluid/tests/unittests/test_mean_op.py @@ -22,6 +22,7 @@ import paddle.fluid.core as core class TestMeanOp(OpTest): def setUp(self): + self.test_gc = True self.op_type = "mean" self.dtype = np.float32 self.init_dtype_type() diff --git a/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py b/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py index eb82af75e4a..62cfc08d15f 100644 --- a/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py +++ b/python/paddle/fluid/tests/unittests/test_nearest_interp_op.py @@ -67,6 +67,7 @@ def nearest_neighbor_interp_np(X, class TestNearestInterpOp(OpTest): def setUp(self): + self.test_gc = True self.out_size = None self.actual_shape = None self.init_test_case() @@ -189,6 +190,7 @@ class TestNearestNeighborInterpActualShape(TestNearestInterpOp): class TestNearestInterpOpUint8(OpTest): def setUp(self): + self.test_gc = True self.out_size = None self.actual_shape = None self.init_test_case() diff --git a/python/paddle/fluid/tests/unittests/test_pad2d_op.py b/python/paddle/fluid/tests/unittests/test_pad2d_op.py index 5c4a6ca59e5..85e589a4ab4 100644 --- a/python/paddle/fluid/tests/unittests/test_pad2d_op.py +++ b/python/paddle/fluid/tests/unittests/test_pad2d_op.py @@ -19,6 +19,7 @@ from op_test import OpTest class TestPad2dOp(OpTest): def setUp(self): + self.test_gc = True self.pad_value = 0.0 self.variable_paddings = False self.initTestCase() diff --git a/python/paddle/fluid/tests/unittests/test_scatter_op.py b/python/paddle/fluid/tests/unittests/test_scatter_op.py index 088996f9d7d..3f4edbbb13b 100644 --- a/python/paddle/fluid/tests/unittests/test_scatter_op.py +++ b/python/paddle/fluid/tests/unittests/test_scatter_op.py @@ -21,6 +21,7 @@ from op_test import OpTest class TestScatterOp(OpTest): def setUp(self): + self.test_gc = True self.op_type = "scatter" ref_np = np.ones((3, 3)).astype("float32") index_np = np.array([1, 2]).astype("int32") diff --git a/python/paddle/fluid/tests/unittests/test_seq_conv.py b/python/paddle/fluid/tests/unittests/test_seq_conv.py index da111f9b734..d0c69abd701 100644 --- a/python/paddle/fluid/tests/unittests/test_seq_conv.py +++ b/python/paddle/fluid/tests/unittests/test_seq_conv.py @@ -69,6 +69,7 @@ def seqconv(x, class TestSeqProject(OpTest): def setUp(self): + self.test_gc = True self.init_test_case() self.op_type = 'sequence_conv' diff --git a/python/paddle/fluid/tests/unittests/test_seq_pool.py b/python/paddle/fluid/tests/unittests/test_seq_pool.py index 176265428c8..e84aefb582d 100644 --- a/python/paddle/fluid/tests/unittests/test_seq_pool.py +++ b/python/paddle/fluid/tests/unittests/test_seq_pool.py @@ -56,6 +56,7 @@ class TestSeqAvgPool(OpTest): compute_seqpool_avg(x, offset, out) def setUp(self): + self.test_gc = True x, offset, out = self.set_data() self.compute(x, offset, out) diff --git a/python/paddle/fluid/tests/unittests/test_sequence_concat.py b/python/paddle/fluid/tests/unittests/test_sequence_concat.py index b4a40edc6ac..a5d26a2ca25 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_concat.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_concat.py @@ -26,6 +26,7 @@ class TestSequenceConcat(OpTest): self.out_lod = [19, 11] def setUp(self): + self.test_gc = True x1 = np.random.random(size=(10, 80)) x2 = np.random.random(size=(20, 80)) self.setLoD() diff --git a/python/paddle/fluid/tests/unittests/test_sequence_expand.py b/python/paddle/fluid/tests/unittests/test_sequence_expand.py index 1e4d1119789..fd1cd5a4bd2 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_expand.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_expand.py @@ -67,6 +67,7 @@ class TestSequenceExpand(OpTest): self.outputs = {'Out': (out, out_lod)} def setUp(self): + self.test_gc = True self.op_type = 'sequence_expand' self.set_data() self.compute() diff --git a/python/paddle/fluid/tests/unittests/test_sequence_expand_as.py b/python/paddle/fluid/tests/unittests/test_sequence_expand_as.py index 30c487eea3d..7593628dbc0 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_expand_as.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_expand_as.py @@ -21,6 +21,7 @@ from op_test import OpTest class TestSequenceExpandAs(OpTest): def setUp(self): + self.test_gc = True self.op_type = 'sequence_expand_as' self.set_data() self.compute() diff --git a/python/paddle/fluid/tests/unittests/test_sequence_pad_op.py b/python/paddle/fluid/tests/unittests/test_sequence_pad_op.py index d5ab9e89fc2..75ed45b5c79 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_pad_op.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_pad_op.py @@ -66,6 +66,7 @@ class TestSequencePadOp(OpTest): self.outputs = {'Out': out_data, 'Length': length} def setUp(self): + self.test_gc = True self.op_type = 'sequence_pad' self.set_attr() self.set_data() diff --git a/python/paddle/fluid/tests/unittests/test_sequence_scatter_op.py b/python/paddle/fluid/tests/unittests/test_sequence_scatter_op.py index 4ffe2c2a12b..209e3d34884 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_scatter_op.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_scatter_op.py @@ -22,6 +22,7 @@ class TestSequenceScatterOp(OpTest): return [[3, 5, 4]] def setUp(self): + self.test_gc = True self.op_type = "sequence_scatter" X_data = np.random.uniform(0.1, 1.0, [3, 6]).astype('float32') diff --git a/python/paddle/fluid/tests/unittests/test_sequence_slice_op.py b/python/paddle/fluid/tests/unittests/test_sequence_slice_op.py index 9c5492b5b15..1c384e0eb7c 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_slice_op.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_slice_op.py @@ -49,6 +49,7 @@ class TestSequenceSliceOp(OpTest): self.length = [[10], [8], [6], [4], [2]] def setUp(self): + self.test_gc = True self.op_type = "sequence_slice" self.set_data() diff --git a/python/paddle/fluid/tests/unittests/test_sequence_unpad_op.py b/python/paddle/fluid/tests/unittests/test_sequence_unpad_op.py index 0e65108c717..628d468aa13 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_unpad_op.py +++ b/python/paddle/fluid/tests/unittests/test_sequence_unpad_op.py @@ -46,6 +46,7 @@ class TestSequenceUnpadOp(OpTest): self.outputs = {'Out': (out.reshape(out_shape), out_lod)} def setUp(self): + self.test_gc = True self.op_type = 'sequence_unpad' self.init() self.compute() diff --git a/python/paddle/fluid/tests/unittests/test_slice_op.py b/python/paddle/fluid/tests/unittests/test_slice_op.py index aefd8cb6d3a..5b3c513fb24 100644 --- a/python/paddle/fluid/tests/unittests/test_slice_op.py +++ b/python/paddle/fluid/tests/unittests/test_slice_op.py @@ -22,6 +22,7 @@ from op_test import OpTest class TestSliceOp(OpTest): def setUp(self): + self.test_gc = True self.op_type = "slice" self.config() self.inputs = {'Input': self.input} diff --git a/python/paddle/fluid/tests/unittests/test_space_to_depth_op.py b/python/paddle/fluid/tests/unittests/test_space_to_depth_op.py index 5fdad44f124..ad4c4975c1c 100644 --- a/python/paddle/fluid/tests/unittests/test_space_to_depth_op.py +++ b/python/paddle/fluid/tests/unittests/test_space_to_depth_op.py @@ -41,6 +41,7 @@ class TestSpaceToDepthOp(OpTest): out_[in_index] = in_[out_index] def setUp(self): + self.test_gc = True self.init_data() self.op_type = "space_to_depth" diff --git a/python/paddle/fluid/tests/unittests/test_squared_l2_distance_op.py b/python/paddle/fluid/tests/unittests/test_squared_l2_distance_op.py index a8bc1004d9b..423e68020df 100644 --- a/python/paddle/fluid/tests/unittests/test_squared_l2_distance_op.py +++ b/python/paddle/fluid/tests/unittests/test_squared_l2_distance_op.py @@ -21,6 +21,7 @@ from op_test import OpTest class TestSquaredL2DistanceOp_f0(OpTest): def setUp(self): + self.test_gc = True self.op_type = "squared_l2_distance" self.inputs = { 'X': np.random.uniform(0.1, 0.6, (2, 3)).astype("float32"), @@ -42,6 +43,7 @@ class TestSquaredL2DistanceOp_f0(OpTest): class TestSquaredL2DistanceOp_f1(OpTest): def setUp(self): + self.test_gc = True self.op_type = "squared_l2_distance" self.inputs = { 'X': np.random.uniform(0.1, 0.6, (2, 3)).astype("float32"), @@ -63,6 +65,7 @@ class TestSquaredL2DistanceOp_f1(OpTest): class TestSquaredL2DistanceOp_f2(OpTest): def setUp(self): + self.test_gc = True self.op_type = "squared_l2_distance" self.inputs = { 'X': np.random.uniform(0.1, 0.6, (2, 3, 4)).astype("float32"), diff --git a/python/paddle/fluid/tests/unittests/test_uniform_random_batch_size_like_op.py b/python/paddle/fluid/tests/unittests/test_uniform_random_batch_size_like_op.py index 7b8be24d9da..27627000686 100644 --- a/python/paddle/fluid/tests/unittests/test_uniform_random_batch_size_like_op.py +++ b/python/paddle/fluid/tests/unittests/test_uniform_random_batch_size_like_op.py @@ -21,6 +21,7 @@ from op_test import OpTest class TestUniformRandomBatchSizeLike(OpTest): def setUp(self): + self.test_gc = True self.op_type = "uniform_random_batch_size_like" self.inputs = {'Input': np.zeros((500, 2000), dtype="float32")} self.attrs = {'min': 1., 'max': 2., 'shape': [-1, 2000]} -- GitLab