Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions test/deprecated/sequence/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,3 @@ string(REPLACE ".py" "" TEST_OPS "${TEST_OPS}")
foreach(TEST_OP ${TEST_OPS})
py_test_modules(${TEST_OP} MODULES ${TEST_OP})
endforeach()
set_tests_properties(test_sequence_conv PROPERTIES TIMEOUT 120)
set_tests_properties(test_sequence_pool PROPERTIES TIMEOUT 120)

set(PIR_COVERAGE_TESTS test_sequence_mask)

foreach(PIR_COVERAGE_TEST ${PIR_COVERAGE_TESTS})
py_test_modules(${PIR_COVERAGE_TEST}_pir MODULES ${PIR_COVERAGE_TEST} ENVS
FLAGS_enable_pir_in_executor=true)
set_tests_properties(${PIR_COVERAGE_TEST}_pir PROPERTIES TIMEOUT 120)
message(STATUS "PIR Copied OpTest: ${PIR_COVERAGE_TEST}_pir in sequence test")
endforeach()
43 changes: 43 additions & 0 deletions test/deprecated/sequence/test_sequence_conv_deprecated.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# 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 unittest

import numpy as np

import paddle

paddle.enable_static()


class TestSeqConvApi(unittest.TestCase):
def test_api(self):
from paddle import base

x = paddle.static.data('x', shape=[-1, 32], lod_level=1)
y = paddle.static.nn.sequence_lod.sequence_conv(
input=x, num_filters=2, filter_size=3, padding_start=None
)

place = base.CPUPlace()
x_tensor = base.create_lod_tensor(
np.random.rand(10, 32).astype("float32"), [[2, 3, 1, 4]], place
)
exe = base.Executor(place)
exe.run(base.default_startup_program())
ret = exe.run(feed={'x': x_tensor}, fetch_list=[y], return_numpy=False)


if __name__ == '__main__':
unittest.main()
29 changes: 15 additions & 14 deletions test/legacy_test/op_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3283,20 +3283,21 @@ def check_grad_with_place(
if numeric_place is None:
numeric_place = place

numeric_grads = self.check_grad_with_place_for_static(
user_defined_grads,
inputs_to_check,
place,
output_names,
no_grad_set,
user_defined_grad_outputs,
numeric_place,
numeric_grad_delta,
in_place,
check_cinn,
max_relative_error,
atol,
)
with paddle.pir_utils.OldIrGuard():
numeric_grads = self.check_grad_with_place_for_static(
user_defined_grads,
inputs_to_check,
place,
output_names,
no_grad_set,
user_defined_grad_outputs,
numeric_place,
numeric_grad_delta,
in_place,
check_cinn,
max_relative_error,
atol,
)

if check_pir_onednn and isinstance(
place, paddle.base.libpaddle.CPUPlace
Expand Down
2 changes: 1 addition & 1 deletion test/legacy_test/test_fusion_seqconv_eltadd_relu_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import numpy as np
from op_test import OpTest

sys.path.append("../deprecated/sequence")
sys.path.append("../sequence")
from test_sequence_conv import seqconv


Expand Down
2 changes: 1 addition & 1 deletion test/legacy_test/test_fusion_seqpool_concat_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import numpy as np
from op_test import OpTest

sys.path.append("../deprecated/sequence")
sys.path.append("../sequence")
from test_sequence_pool import (
compute_seqpool_avg,
compute_seqpool_sqrt,
Expand Down
2 changes: 1 addition & 1 deletion test/legacy_test/test_fusion_seqpool_cvm_concat_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import numpy as np
from op_test import OpTest

sys.path.append("../deprecated/sequence")
sys.path.append("../sequence")
from test_cvm_op import cvm_compute
from test_sequence_pool import (
compute_seqpool_avg,
Expand Down
5 changes: 5 additions & 0 deletions test/sequence/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ foreach(TEST_OP ${TEST_OPS})
py_test_modules(${TEST_OP} MODULES ${TEST_OP})
endforeach()

set(PIR_COVERAGE_TESTS test_sequence_mask)

foreach(PIR_COVERAGE_TEST ${PIR_COVERAGE_TESTS})
py_test_modules(${PIR_COVERAGE_TEST}_pir MODULES ${PIR_COVERAGE_TEST} ENVS
FLAGS_enable_pir_in_executor=true)
set_tests_properties(${PIR_COVERAGE_TEST}_pir PROPERTIES TIMEOUT 120)
message(STATUS "PIR Copied OpTest: ${PIR_COVERAGE_TEST}_pir in sequence test")
endforeach()

set_tests_properties(test_sequence_conv PROPERTIES TIMEOUT 120)
set_tests_properties(test_sequence_pool PROPERTIES TIMEOUT 120)
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import numpy as np
from op_test import OpTest

import paddle


def seqconv(
x,
Expand Down Expand Up @@ -290,23 +288,5 @@ def init_test_case(self):
self.output_represention = 8 # output feature size


class TestSeqConvApi(unittest.TestCase):
def test_api(self):
from paddle import base

x = paddle.static.data('x', shape=[-1, 32], lod_level=1)
y = paddle.static.nn.sequence_lod.sequence_conv(
input=x, num_filters=2, filter_size=3, padding_start=None
)

place = base.CPUPlace()
x_tensor = base.create_lod_tensor(
np.random.rand(10, 32).astype("float32"), [[2, 3, 1, 4]], place
)
exe = base.Executor(place)
exe.run(base.default_startup_program())
ret = exe.run(feed={'x': x_tensor}, fetch_list=[y], return_numpy=False)


if __name__ == '__main__':
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import paddle
from paddle.base.framework import (
convert_np_dtype_to_dtype_,
convert_np_dtype_to_proto_type,
)
from paddle.pir_utils import test_with_pir_api

Expand Down Expand Up @@ -60,7 +60,7 @@ def setUp(self):
self.outputs = {'Y': self.calc_ground_truth_mask()}
self.attrs = {
'maxlen': self.maxlen,
'out_dtype': convert_np_dtype_to_dtype_(self.mask_dtype),
'out_dtype': convert_np_dtype_to_proto_type(self.mask_dtype),
}

def calc_ground_truth_mask(self):
Expand Down Expand Up @@ -129,7 +129,9 @@ def setUp(self):

self.inputs = {'X': self.x, 'MaxLenTensor': self.maxlen_tensor}
self.outputs = {'Y': self.calc_ground_truth_mask()}
self.attrs = {'out_dtype': convert_np_dtype_to_dtype_(self.mask_dtype)}
self.attrs = {
'out_dtype': convert_np_dtype_to_proto_type(self.mask_dtype)
}

def calc_ground_truth_mask(self):
maxlen = np.max(self.x) if self.maxlen < 0 else self.maxlen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import numpy as np
from op_test import OpTest

sys.path.append("../legacy_test")
sys.path.append("../deprecated/legacy_test")
from test_softmax_op import stable_softmax

from paddle.base import core
Expand Down