From 8439384e257f6a69b6afe5d1944cdf1a0c4af3c2 Mon Sep 17 00:00:00 2001 From: songyouwei Date: Wed, 25 Dec 2019 14:13:24 +0800 Subject: [PATCH] Move sequence op unittest files to a separate folder sequence (#21842) * move sequence op unittests to a separate folder test=develop * add missing CMakeList file test=develop * fix relative path import test=develop * fix relative import test=develop * use sys.path.append test=develop --- python/paddle/fluid/tests/unittests/CMakeLists.txt | 2 ++ .../fluid/tests/unittests/sequence/CMakeLists.txt | 6 ++++++ .../fluid/tests/unittests/sequence/__init__.py | 13 +++++++++++++ .../tests/unittests/{ => sequence}/test_seq_conv.py | 2 ++ .../tests/unittests/{ => sequence}/test_seq_pool.py | 2 ++ .../{ => sequence}/test_sequence_concat.py | 2 ++ .../{ => sequence}/test_sequence_enumerate_op.py | 2 ++ .../{ => sequence}/test_sequence_erase_op.py | 2 ++ .../{ => sequence}/test_sequence_expand.py | 2 ++ .../{ => sequence}/test_sequence_expand_as.py | 2 ++ .../unittests/{ => sequence}/test_sequence_mask.py | 4 +++- .../{ => sequence}/test_sequence_pad_op.py | 2 ++ .../{ => sequence}/test_sequence_reshape.py | 2 ++ .../{ => sequence}/test_sequence_reverse.py | 4 +++- .../{ => sequence}/test_sequence_scatter_op.py | 2 ++ .../{ => sequence}/test_sequence_slice_op.py | 1 + .../{ => sequence}/test_sequence_softmax_op.py | 4 +++- .../test_sequence_topk_avg_pooling.py | 4 +++- .../{ => sequence}/test_sequence_unpad_op.py | 2 ++ .../unittests/test_fusion_seqconv_eltadd_relu_op.py | 2 +- .../unittests/test_fusion_seqpool_concat_op.py | 2 +- .../unittests/test_fusion_seqpool_cvm_concat_op.py | 2 +- 22 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 python/paddle/fluid/tests/unittests/sequence/CMakeLists.txt create mode 100644 python/paddle/fluid/tests/unittests/sequence/__init__.py rename python/paddle/fluid/tests/unittests/{ => sequence}/test_seq_conv.py (99%) rename python/paddle/fluid/tests/unittests/{ => sequence}/test_seq_pool.py (99%) rename python/paddle/fluid/tests/unittests/{ => sequence}/test_sequence_concat.py (98%) rename python/paddle/fluid/tests/unittests/{ => sequence}/test_sequence_enumerate_op.py (99%) rename python/paddle/fluid/tests/unittests/{ => sequence}/test_sequence_erase_op.py (99%) rename python/paddle/fluid/tests/unittests/{ => sequence}/test_sequence_expand.py (99%) rename python/paddle/fluid/tests/unittests/{ => sequence}/test_sequence_expand_as.py (98%) rename python/paddle/fluid/tests/unittests/{ => sequence}/test_sequence_mask.py (99%) rename python/paddle/fluid/tests/unittests/{ => sequence}/test_sequence_pad_op.py (99%) rename python/paddle/fluid/tests/unittests/{ => sequence}/test_sequence_reshape.py (98%) rename python/paddle/fluid/tests/unittests/{ => sequence}/test_sequence_reverse.py (98%) rename python/paddle/fluid/tests/unittests/{ => sequence}/test_sequence_scatter_op.py (98%) rename python/paddle/fluid/tests/unittests/{ => sequence}/test_sequence_slice_op.py (99%) rename python/paddle/fluid/tests/unittests/{ => sequence}/test_sequence_softmax_op.py (98%) rename python/paddle/fluid/tests/unittests/{ => sequence}/test_sequence_topk_avg_pooling.py (99%) rename python/paddle/fluid/tests/unittests/{ => sequence}/test_sequence_unpad_op.py (98%) diff --git a/python/paddle/fluid/tests/unittests/CMakeLists.txt b/python/paddle/fluid/tests/unittests/CMakeLists.txt index b61c7ea04b4..867d1a6178e 100644 --- a/python/paddle/fluid/tests/unittests/CMakeLists.txt +++ b/python/paddle/fluid/tests/unittests/CMakeLists.txt @@ -305,6 +305,8 @@ set_tests_properties(test_parallel_executor_seresnext_base_cpu PROPERTIES TIMEOU set_tests_properties(test_parallel_executor_seresnext_with_reduce_cpu PROPERTIES TIMEOUT 750) set_tests_properties(test_parallel_executor_seresnext_with_fuse_all_reduce_cpu PROPERTIES TIMEOUT 750) +add_subdirectory(sequence) + if (WITH_NGRAPH) add_subdirectory(ngraph) endif() diff --git a/python/paddle/fluid/tests/unittests/sequence/CMakeLists.txt b/python/paddle/fluid/tests/unittests/sequence/CMakeLists.txt new file mode 100644 index 00000000000..f71e04c09aa --- /dev/null +++ b/python/paddle/fluid/tests/unittests/sequence/CMakeLists.txt @@ -0,0 +1,6 @@ +file(GLOB TEST_OPS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "test_*.py") +string(REPLACE ".py" "" TEST_OPS "${TEST_OPS}") + +foreach(TEST_OP ${TEST_OPS}) + py_test_modules(${TEST_OP} MODULES ${TEST_OP}) +endforeach(TEST_OP) diff --git a/python/paddle/fluid/tests/unittests/sequence/__init__.py b/python/paddle/fluid/tests/unittests/sequence/__init__.py new file mode 100644 index 00000000000..f106fc5f103 --- /dev/null +++ b/python/paddle/fluid/tests/unittests/sequence/__init__.py @@ -0,0 +1,13 @@ +# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserve. +# +# 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. diff --git a/python/paddle/fluid/tests/unittests/test_seq_conv.py b/python/paddle/fluid/tests/unittests/sequence/test_seq_conv.py similarity index 99% rename from python/paddle/fluid/tests/unittests/test_seq_conv.py rename to python/paddle/fluid/tests/unittests/sequence/test_seq_conv.py index 84db84977b1..f578f3bdfb3 100644 --- a/python/paddle/fluid/tests/unittests/test_seq_conv.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_seq_conv.py @@ -17,6 +17,8 @@ from __future__ import print_function import unittest import numpy as np import random +import sys +sys.path.append("../") from op_test import OpTest diff --git a/python/paddle/fluid/tests/unittests/test_seq_pool.py b/python/paddle/fluid/tests/unittests/sequence/test_seq_pool.py similarity index 99% rename from python/paddle/fluid/tests/unittests/test_seq_pool.py rename to python/paddle/fluid/tests/unittests/sequence/test_seq_pool.py index 9087b9cc012..94eb091bc01 100644 --- a/python/paddle/fluid/tests/unittests/test_seq_pool.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_seq_pool.py @@ -16,6 +16,8 @@ from __future__ import print_function import unittest import numpy as np +import sys +sys.path.append("../") from op_test import OpTest, skip_check_grad_ci from test_reorder_lod_tensor import convert_to_offset diff --git a/python/paddle/fluid/tests/unittests/test_sequence_concat.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_concat.py similarity index 98% rename from python/paddle/fluid/tests/unittests/test_sequence_concat.py rename to python/paddle/fluid/tests/unittests/sequence/test_sequence_concat.py index 2dacbb5ae99..5b3d55c8493 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_concat.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_concat.py @@ -16,6 +16,8 @@ from __future__ import print_function import unittest import numpy as np +import sys +sys.path.append("../") from op_test import OpTest diff --git a/python/paddle/fluid/tests/unittests/test_sequence_enumerate_op.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_enumerate_op.py similarity index 99% rename from python/paddle/fluid/tests/unittests/test_sequence_enumerate_op.py rename to python/paddle/fluid/tests/unittests/sequence/test_sequence_enumerate_op.py index 99bb33a0a5e..9878e6f7413 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_enumerate_op.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_enumerate_op.py @@ -16,6 +16,8 @@ from __future__ import print_function import unittest import numpy as np +import sys +sys.path.append("../") from op_test import OpTest diff --git a/python/paddle/fluid/tests/unittests/test_sequence_erase_op.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_erase_op.py similarity index 99% rename from python/paddle/fluid/tests/unittests/test_sequence_erase_op.py rename to python/paddle/fluid/tests/unittests/sequence/test_sequence_erase_op.py index 53bb301e9a2..9e060201fe8 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_erase_op.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_erase_op.py @@ -16,6 +16,8 @@ from __future__ import print_function import unittest import numpy as np +import sys +sys.path.append("../") from op_test import OpTest diff --git a/python/paddle/fluid/tests/unittests/test_sequence_expand.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_expand.py similarity index 99% rename from python/paddle/fluid/tests/unittests/test_sequence_expand.py rename to python/paddle/fluid/tests/unittests/sequence/test_sequence_expand.py index 41d2b8bea49..51e6f31d9cb 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_expand.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_expand.py @@ -16,6 +16,8 @@ from __future__ import print_function import unittest import numpy as np +import sys +sys.path.append("../") from op_test import OpTest diff --git a/python/paddle/fluid/tests/unittests/test_sequence_expand_as.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_expand_as.py similarity index 98% rename from python/paddle/fluid/tests/unittests/test_sequence_expand_as.py rename to python/paddle/fluid/tests/unittests/sequence/test_sequence_expand_as.py index f3b9f3897c1..f038b00a3bd 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_expand_as.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_expand_as.py @@ -16,6 +16,8 @@ from __future__ import print_function import unittest import numpy as np +import sys +sys.path.append("../") from op_test import OpTest diff --git a/python/paddle/fluid/tests/unittests/test_sequence_mask.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_mask.py similarity index 99% rename from python/paddle/fluid/tests/unittests/test_sequence_mask.py rename to python/paddle/fluid/tests/unittests/sequence/test_sequence_mask.py index 7e9f4cb5601..f1efb78d786 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_mask.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_mask.py @@ -12,13 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -from op_test import OpTest import paddle.fluid as fluid from paddle.fluid.framework import convert_np_dtype_to_dtype_ import paddle.fluid.core as core import numpy as np import copy import unittest +import sys +sys.path.append("../") +from op_test import OpTest class SequenceMaskTestBase(OpTest): diff --git a/python/paddle/fluid/tests/unittests/test_sequence_pad_op.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_pad_op.py similarity index 99% rename from python/paddle/fluid/tests/unittests/test_sequence_pad_op.py rename to python/paddle/fluid/tests/unittests/sequence/test_sequence_pad_op.py index dfb7b7e7745..a710fc5ce8b 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_pad_op.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_pad_op.py @@ -14,6 +14,8 @@ import unittest import numpy as np +import sys +sys.path.append("../") from op_test import OpTest diff --git a/python/paddle/fluid/tests/unittests/test_sequence_reshape.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_reshape.py similarity index 98% rename from python/paddle/fluid/tests/unittests/test_sequence_reshape.py rename to python/paddle/fluid/tests/unittests/sequence/test_sequence_reshape.py index c72e5dbaf80..4c65cd382ff 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_reshape.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_reshape.py @@ -17,6 +17,8 @@ from __future__ import print_function import unittest import numpy as np import math +import sys +sys.path.append("../") from op_test import OpTest diff --git a/python/paddle/fluid/tests/unittests/test_sequence_reverse.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_reverse.py similarity index 98% rename from python/paddle/fluid/tests/unittests/test_sequence_reverse.py rename to python/paddle/fluid/tests/unittests/sequence/test_sequence_reverse.py index 2b8f9860664..8c709984915 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_reverse.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_reverse.py @@ -15,8 +15,10 @@ import unittest import paddle.fluid as fluid import paddle.fluid.core as core -from op_test import OpTest import numpy as np +import sys +sys.path.append("../") +from op_test import OpTest class TestSequenceReverseBase(OpTest): diff --git a/python/paddle/fluid/tests/unittests/test_sequence_scatter_op.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_scatter_op.py similarity index 98% rename from python/paddle/fluid/tests/unittests/test_sequence_scatter_op.py rename to python/paddle/fluid/tests/unittests/sequence/test_sequence_scatter_op.py index 44fece075a4..153efd9182d 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_scatter_op.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_scatter_op.py @@ -14,6 +14,8 @@ import unittest import numpy as np +import sys +sys.path.append("../") from op_test import OpTest diff --git a/python/paddle/fluid/tests/unittests/test_sequence_slice_op.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_slice_op.py similarity index 99% rename from python/paddle/fluid/tests/unittests/test_sequence_slice_op.py rename to python/paddle/fluid/tests/unittests/sequence/test_sequence_slice_op.py index 9c5492b5b15..4d254ea6d4f 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_slice_op.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_slice_op.py @@ -17,6 +17,7 @@ from __future__ import print_function import unittest import numpy as np import sys +sys.path.append("../") from op_test import OpTest diff --git a/python/paddle/fluid/tests/unittests/test_sequence_softmax_op.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_softmax_op.py similarity index 98% rename from python/paddle/fluid/tests/unittests/test_sequence_softmax_op.py rename to python/paddle/fluid/tests/unittests/sequence/test_sequence_softmax_op.py index 0ff8c5330fd..92146820da1 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_softmax_op.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_softmax_op.py @@ -16,9 +16,11 @@ from __future__ import print_function import unittest import numpy as np +import paddle.fluid.core as core +import sys +sys.path.append("../") from op_test import OpTest from test_softmax_op import stable_softmax -import paddle.fluid.core as core class TestSequenceSoftmaxOp(OpTest): diff --git a/python/paddle/fluid/tests/unittests/test_sequence_topk_avg_pooling.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_topk_avg_pooling.py similarity index 99% rename from python/paddle/fluid/tests/unittests/test_sequence_topk_avg_pooling.py rename to python/paddle/fluid/tests/unittests/sequence/test_sequence_topk_avg_pooling.py index 840997d4a19..025455e47be 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_topk_avg_pooling.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_topk_avg_pooling.py @@ -16,8 +16,10 @@ from __future__ import print_function import unittest import numpy as np -from op_test import OpTest from copy import deepcopy +import sys +sys.path.append("../") +from op_test import OpTest class TestSequenceTopkAvgPoolingOp(OpTest): diff --git a/python/paddle/fluid/tests/unittests/test_sequence_unpad_op.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_unpad_op.py similarity index 98% rename from python/paddle/fluid/tests/unittests/test_sequence_unpad_op.py rename to python/paddle/fluid/tests/unittests/sequence/test_sequence_unpad_op.py index 3905d7bf3cf..a37f7b58ee5 100644 --- a/python/paddle/fluid/tests/unittests/test_sequence_unpad_op.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_unpad_op.py @@ -15,6 +15,8 @@ import unittest import six import numpy as np +import sys +sys.path.append("../") from op_test import OpTest diff --git a/python/paddle/fluid/tests/unittests/test_fusion_seqconv_eltadd_relu_op.py b/python/paddle/fluid/tests/unittests/test_fusion_seqconv_eltadd_relu_op.py index ba6f1415b1c..bd5e1895aa6 100644 --- a/python/paddle/fluid/tests/unittests/test_fusion_seqconv_eltadd_relu_op.py +++ b/python/paddle/fluid/tests/unittests/test_fusion_seqconv_eltadd_relu_op.py @@ -18,7 +18,7 @@ import unittest import numpy as np import random from op_test import OpTest -from test_seq_conv import seqconv +from sequence.test_seq_conv import seqconv class TestSeqConvEltAddRelu(OpTest): diff --git a/python/paddle/fluid/tests/unittests/test_fusion_seqpool_concat_op.py b/python/paddle/fluid/tests/unittests/test_fusion_seqpool_concat_op.py index 8a6837dae2c..d8054a85cb6 100644 --- a/python/paddle/fluid/tests/unittests/test_fusion_seqpool_concat_op.py +++ b/python/paddle/fluid/tests/unittests/test_fusion_seqpool_concat_op.py @@ -18,7 +18,7 @@ import unittest import numpy as np from op_test import OpTest from test_reorder_lod_tensor import convert_to_offset -from test_seq_pool import compute_seqpool_sum, compute_seqpool_avg, compute_seqpool_sqrt +from sequence.test_seq_pool import compute_seqpool_sum, compute_seqpool_avg, compute_seqpool_sqrt class TestFusionSeqPoolConcatOp(OpTest): diff --git a/python/paddle/fluid/tests/unittests/test_fusion_seqpool_cvm_concat_op.py b/python/paddle/fluid/tests/unittests/test_fusion_seqpool_cvm_concat_op.py index 332f48ae71a..a4dd2659dcb 100644 --- a/python/paddle/fluid/tests/unittests/test_fusion_seqpool_cvm_concat_op.py +++ b/python/paddle/fluid/tests/unittests/test_fusion_seqpool_cvm_concat_op.py @@ -18,7 +18,7 @@ import unittest import numpy as np from op_test import OpTest from test_reorder_lod_tensor import convert_to_offset -from test_seq_pool import compute_seqpool_sum, compute_seqpool_avg, compute_seqpool_sqrt +from sequence.test_seq_pool import compute_seqpool_sum, compute_seqpool_avg, compute_seqpool_sqrt from test_cvm_op import cvm_compute -- GitLab