Skip to content

Commit 827bbce

Browse files
【Fix PIR Unittest No.84,94,96,98,100,102,103,105,106,107,109,111,114,116,117,122,128,130,131,132,144,145,153,155,156,159,160,161,162,165,167,172,182,183,184,186,187,188,189,195,199,203,205,214,216,218,220,221,222,226,227,228,229,234,238,246,247,253,254,255,260,264,265,270,273,281,289,294,302,303,304,306,310,311,318,325,328,331,332,333,334,335,337,339,340,343,345,346,347,349,350,351,354,357,360,361,364,365,368,371,372,375,376,379,383,387,394,397,410,414,418,421,424,430,450,454,457,458,468,470,471,473,485,488,489,494,496,502,503,518,520,521,524,532,535,538,539】Fix some test case in PIR (#64754)
* move out pir open test case from deprecated
1 parent 0b6770d commit 827bbce

File tree

147 files changed

+209
-286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+209
-286
lines changed

test/deprecated/legacy_test/CMakeLists.txt

Lines changed: 3 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ endif()
130130

131131
if(WIN32)
132132
list(REMOVE_ITEM TEST_OPS test_complex_matmul)
133-
list(REMOVE_ITEM TEST_OPS test_ops_nms)
134133
list(REMOVE_ITEM TEST_OPS test_trt_convert_preln_residual_bias)
135134
list(REMOVE_ITEM TEST_OPS test_masked_multihead_attention_op)
136135
list(REMOVE_ITEM TEST_OPS test_fused_ec_moe_op)
@@ -401,8 +400,6 @@ endfunction()
401400
list(REMOVE_ITEM TEST_OPS test_feed_data_check_shape_type)
402401
list(REMOVE_ITEM TEST_OPS test_fetch_lod_tensor_array)
403402
list(REMOVE_ITEM TEST_OPS test_data_norm_op)
404-
list(REMOVE_ITEM TEST_OPS test_bilinear_interp_op)
405-
list(REMOVE_ITEM TEST_OPS test_nearest_interp_op)
406403
list(REMOVE_ITEM TEST_OPS test_imperative_mnist_sorted_gradient)
407404
list(REMOVE_ITEM TEST_OPS test_imperative_mnist)
408405
list(REMOVE_ITEM TEST_OPS test_layers_deprecated)
@@ -452,8 +449,7 @@ endif()
452449

453450
# Some ops need to check results when gc is enabled
454451
# Currently, only ops that register NoNeedBufferVarsInference need to do this test
455-
set(TEST_OPS_WITH_GC test_affine_channel_op test_gather_nd_op test_scatter_op
456-
test_slice_op)
452+
set(TEST_OPS_WITH_GC test_gather_nd_op test_slice_op)
457453

458454
foreach(TEST_OP ${TEST_OPS_WITH_GC})
459455
list(REMOVE_ITEM TEST_OPS ${TEST_OP})
@@ -485,10 +481,6 @@ set_tests_properties(test_logcumsumexp_op PROPERTIES TIMEOUT 30)
485481
py_test_modules(test_adam_op_multi_thread MODULES test_adam_op ENVS
486482
FLAGS_inner_op_parallelism=4)
487483

488-
py_test_modules(test_bilinear_interp_op MODULES test_bilinear_interp_op ENVS
489-
${GC_ENVS})
490-
py_test_modules(test_nearest_interp_op MODULES test_nearest_interp_op ENVS
491-
${GC_ENVS})
492484
py_test_modules(test_imperative_mnist MODULES test_imperative_mnist ENVS
493485
FLAGS_cudnn_deterministic=1)
494486
py_test_modules(
@@ -511,8 +503,6 @@ if((WITH_GPU) AND (WITH_CUDNN_FRONTEND))
511503
test_fused_dot_product_attention_op)
512504
endif()
513505

514-
set_tests_properties(test_conv2d_op_depthwise_conv
515-
PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE")
516506
set_tests_properties(test_conv2d_api_deprecated PROPERTIES LABELS
517507
"RUN_TYPE=EXCLUSIVE")
518508
set_tests_properties(test_conv_nn_grad PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE")
@@ -644,17 +634,10 @@ endif()
644634
set_tests_properties(test_cross_op PROPERTIES TIMEOUT 120)
645635
set_tests_properties(test_imperative_lod_tensor_to_selected_rows
646636
PROPERTIES TIMEOUT 200)
647-
set_tests_properties(test_lstm_op PROPERTIES TIMEOUT 120)
648-
set_tests_properties(test_imperative_star_gan_with_gradient_penalty
649-
PROPERTIES TIMEOUT 120)
650637

651-
set_tests_properties(test_bicubic_interp_op PROPERTIES TIMEOUT 120)
652638
set_tests_properties(test_deformable_conv_op PROPERTIES TIMEOUT 200)
653-
set_tests_properties(test_nearest_interp_op PROPERTIES TIMEOUT 120)
654639
set_tests_properties(test_inplace_softmax_with_cross_entropy PROPERTIES TIMEOUT
655640
120)
656-
set_tests_properties(test_cross_entropy2_op PROPERTIES TIMEOUT 120)
657-
set_tests_properties(test_gru_unit_op PROPERTIES TIMEOUT 120)
658641
set_tests_properties(test_regularizer_api PROPERTIES TIMEOUT 150)
659642
if(NOT WIN32)
660643
if(WITH_NV_JETSON)
@@ -666,75 +649,45 @@ set_tests_properties(test_bilateral_slice_op PROPERTIES TIMEOUT 120)
666649
set_tests_properties(test_fleet_util PROPERTIES TIMEOUT 120)
667650
set_tests_properties(test_imperative_transformer_sorted_gradient
668651
PROPERTIES TIMEOUT 120)
669-
set_tests_properties(test_matmul_op PROPERTIES TIMEOUT 120)
670-
set_tests_properties(test_nearest_interp_v2_op PROPERTIES TIMEOUT 120)
671-
set_tests_properties(test_trilinear_interp_op PROPERTIES TIMEOUT 120)
672652
set_tests_properties(test_static_save_load PROPERTIES TIMEOUT 250)
673-
set_tests_properties(test_paddle_save_load_binary PROPERTIES TIMEOUT 120)
674-
if(WIN32)
675-
set_tests_properties(test_static_save_load_large PROPERTIES TIMEOUT 900)
676-
else()
677-
set_tests_properties(test_static_save_load_large PROPERTIES TIMEOUT 600)
678-
endif()
679653
if(WITH_NV_JETSON)
680654
set_tests_properties(test_conv3d_transpose_part2_op PROPERTIES TIMEOUT 1200)
681655
set_tests_properties(test_layer_norm_op PROPERTIES TIMEOUT 1500)
682-
set_tests_properties(test_pool3d_op PROPERTIES TIMEOUT 1500)
683656
else()
684657
set_tests_properties(test_conv3d_transpose_part2_op PROPERTIES TIMEOUT 120)
685658
set_tests_properties(test_layer_norm_op PROPERTIES TIMEOUT 250)
686-
set_tests_properties(test_pool3d_op PROPERTIES TIMEOUT 150)
687659
endif()
688660

689661
set_tests_properties(test_imperative_selected_rows_to_lod_tensor
690662
PROPERTIES TIMEOUT 200)
691-
set_tests_properties(test_index_select_op PROPERTIES TIMEOUT 120)
692-
set_tests_properties(test_index_add_op PROPERTIES TIMEOUT 120)
693663
set_tests_properties(test_argsort_op PROPERTIES TIMEOUT 120)
694664
set_tests_properties(test_gather_nd_op PROPERTIES TIMEOUT 120)
695-
set_tests_properties(test_row_conv_op PROPERTIES TIMEOUT 120)
696-
set_tests_properties(test_deformable_conv_v1_op PROPERTIES TIMEOUT 300)
697665
set_tests_properties(test_imperative_ptb_rnn_sorted_gradient PROPERTIES TIMEOUT
698666
120)
699-
set_tests_properties(test_crop_tensor_op PROPERTIES TIMEOUT 120)
700667
set_tests_properties(test_imperative_ptb_rnn PROPERTIES TIMEOUT 120)
701-
set_tests_properties(test_svd_op PROPERTIES TIMEOUT 80)
702-
set_tests_properties(test_qr_op PROPERTIES TIMEOUT 60)
703-
set_tests_properties(test_trilinear_interp_v2_op PROPERTIES TIMEOUT 120)
704668
set_tests_properties(test_masked_select_op PROPERTIES TIMEOUT 120)
705669
set_tests_properties(test_sigmoid_cross_entropy_with_logits_op
706670
PROPERTIES TIMEOUT 120)
707671
set_tests_properties(test_imperative_optimizer_v2 PROPERTIES TIMEOUT 150)
708-
set_tests_properties(test_partial_sum_op PROPERTIES TIMEOUT 120)
709672
set_tests_properties(test_sgd_op PROPERTIES TIMEOUT 250)
710673
set_tests_properties(test_generator_dataloader_deprecated PROPERTIES TIMEOUT
711674
120)
712-
set_tests_properties(test_partial_concat_op PROPERTIES TIMEOUT 120)
713675
set_tests_properties(test_reduce_op PROPERTIES TIMEOUT 500)
714676
set_tests_properties(test_conv_nn_grad PROPERTIES TIMEOUT 220)
715677
set_tests_properties(test_program_prune_backward PROPERTIES TIMEOUT 120)
716678
set_tests_properties(test_imperative_optimizer_v2 PROPERTIES TIMEOUT 250)
717-
set_tests_properties(test_bilinear_interp_op PROPERTIES TIMEOUT 120)
718679
set_tests_properties(test_decoupled_py_reader PROPERTIES TIMEOUT 120)
719680
set_tests_properties(test_fuse_bn_act_pass PROPERTIES TIMEOUT 120)
720-
set_tests_properties(test_conv2d_op_depthwise_conv PROPERTIES TIMEOUT 120)
721681
set_tests_properties(test_conv2d_api_deprecated PROPERTIES TIMEOUT 120)
722-
set_tests_properties(test_elementwise_mul_op PROPERTIES TIMEOUT 120)
723682
set_tests_properties(test_dygraph_multi_forward PROPERTIES TIMEOUT 120)
724683
set_tests_properties(test_imperative_ocr_attention_model PROPERTIES TIMEOUT 120)
725684
set_tests_properties(test_imperative_mnist PROPERTIES TIMEOUT 120)
726-
set_tests_properties(test_gru_op PROPERTIES TIMEOUT 200)
727685
set_tests_properties(test_regularizer PROPERTIES TIMEOUT 150)
728-
set_tests_properties(test_matmul_v2_op PROPERTIES TIMEOUT 120)
729686
set_tests_properties(test_slice_op PROPERTIES TIMEOUT 120)
730-
set_tests_properties(test_pad3d_op PROPERTIES TIMEOUT 120)
731687
set_tests_properties(test_dataloader_keep_order PROPERTIES TIMEOUT 120)
732688
set_tests_properties(test_dataloader_unkeep_order PROPERTIES TIMEOUT 120)
733689
set_tests_properties(test_reader_reset PROPERTIES TIMEOUT 120)
734-
set_tests_properties(test_cumprod_op PROPERTIES TIMEOUT 300)
735690
set_tests_properties(test_split_program PROPERTIES TIMEOUT 120)
736-
set_tests_properties(test_graph_send_ue_recv_op PROPERTIES TIMEOUT 60)
737-
set_tests_properties(test_graph_send_uv_op PROPERTIES TIMEOUT 60)
738691
set_tests_properties(test_uniform_random_op_deprecated PROPERTIES TIMEOUT 60)
739692

740693
set_tests_properties(test_pretrained_model PROPERTIES TIMEOUT 120)
@@ -756,36 +709,17 @@ set_tests_properties(test_inplace_addto_strategy_deprecated PROPERTIES TIMEOUT
756709

757710
set(TEST_CINN_OPS
758711
test_softmax_op
759-
test_expand_v2_op
760712
test_reduce_op
761713
test_slice_op
762-
test_full_like_op
763-
test_index_select_op
764-
test_top_k_v2_op
765-
test_elementwise_mul_op
766714
test_gather_nd_op
767-
test_elementwise_pow_op
768-
test_reshape_op
769-
test_meshgrid_op
770715
test_scale_op
771-
test_scatter_op
772716
test_layer_norm_op
773-
test_cast_op
774-
test_roll_op
775-
test_atan2_op
776-
test_top_k_op
777717
test_where_op
778718
test_arg_min_max_op
779-
test_reverse_op
780-
test_flip
781-
test_triangular_solve_op
782719
test_scatter_nd_op
783720
test_instance_norm_op
784721
test_cumsum_op
785-
test_split_op
786-
test_erf_op
787-
test_assign_op
788-
test_flatten_contiguous_range_op)
722+
test_erf_op)
789723

790724
foreach(TEST_CINN_OP ${TEST_CINN_OPS})
791725
if(WITH_CINN)
@@ -810,16 +744,12 @@ set(STATIC_BUILD_TESTS
810744
test_batch_norm_op
811745
test_bincount_op
812746
test_decoupled_py_reader
813-
test_eigh_op
814747
test_fetch_lod_tensor_array
815748
test_fuse_bn_act_pass
816749
test_layer_norm_op
817750
test_lookup_table_v2_op_deprecated
818-
test_matmul_op
819-
test_matmul_v2_op
820751
test_momentum_op
821752
test_nce
822-
test_paddle_save_load_binary
823753
test_reduce_op
824754
test_sparse_conv_op
825755
test_sparse_norm_op
@@ -863,18 +793,13 @@ set_tests_properties(
863793
ENVIRONMENT
864794
"FLAGS_cudnn_deterministic=1;FLAGS_cudnn_batchnorm_spatial_persistent=1;FLAGS_conv_workspace_size_limit=1000"
865795
)
866-
set_tests_properties(test_matmul_op_static_build PROPERTIES TIMEOUT 120)
867-
set_tests_properties(test_matmul_v2_op_static_build PROPERTIES TIMEOUT 120)
868796
set_tests_properties(test_layer_norm_op_static_build PROPERTIES TIMEOUT 1500)
869-
set_tests_properties(test_paddle_save_load_binary_static_build
870-
PROPERTIES TIMEOUT 120)
871797
set_tests_properties(test_reduce_op_static_build PROPERTIES TIMEOUT 500)
872798
py_test_modules(test_stride MODULES test_stride ENVS
873799
FLAGS_use_stride_kernel=true)
874800

875801
set_tests_properties(test_linalg_matrix_exp PROPERTIES TIMEOUT 120)
876802
set_pir_tests_properties()
877803

878-
set_tests_properties(test_fractional_max_pool2d_op PROPERTIES TIMEOUT 120)
879-
880804
set_tests_properties(test_reduce_as_op PROPERTIES TIMEOUT 30)
805+
set_tests_properties(test_attribute_var_deprecated PROPERTIES TIMEOUT 100)

test/deprecated/legacy_test/test_adaptive_avg_pool2d.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import unittest
1717

1818
import numpy as np
19-
from test_attribute_var import UnittestBase
19+
from test_attribute_var_deprecated import UnittestBase
2020

2121
import paddle
2222
from paddle.base import Program, core, program_guard

test/deprecated/legacy_test/test_arg_min_max_op.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import numpy as np
1919
from op_test import OpTest, convert_float_to_uint16
20-
from test_attribute_var import UnittestBase
20+
from test_attribute_var_deprecated import UnittestBase
2121

2222
import paddle
2323
from paddle.base import Program, program_guard
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import os
16+
import tempfile
17+
import unittest
18+
19+
import numpy as np
20+
21+
import paddle
22+
import paddle.inference as paddle_infer
23+
from paddle.base.framework import Program, program_guard
24+
25+
paddle.enable_static()
26+
27+
28+
class UnittestBase(unittest.TestCase):
29+
def setUp(self):
30+
self.temp_dir = tempfile.TemporaryDirectory()
31+
self.init_info()
32+
33+
def tearDwon(self):
34+
self.temp_dir.cleanup()
35+
36+
def init_info(self):
37+
self.shapes = None
38+
self.save_path = None
39+
40+
def path_prefix(self):
41+
return type(self).__name__
42+
43+
def infer_prog(self):
44+
config = paddle_infer.Config(
45+
self.save_path + '.pdmodel', self.save_path + '.pdiparams'
46+
)
47+
config.disable_mkldnn()
48+
predictor = paddle_infer.create_predictor(config)
49+
input_names = predictor.get_input_names()
50+
for i, shape in enumerate(self.shapes):
51+
input_handle = predictor.get_input_handle(input_names[i])
52+
self.fake_input = np.random.randn(*shape).astype("float32")
53+
input_handle.reshape(shape)
54+
input_handle.copy_from_cpu(self.fake_input)
55+
predictor.run()
56+
output_names = predictor.get_output_names()
57+
res = []
58+
for out_name in output_names:
59+
output_handle = predictor.get_output_handle(out_name)
60+
output_data = output_handle.copy_to_cpu()
61+
res.append(output_data)
62+
63+
if len(output_names) == 1:
64+
res = res[0]
65+
66+
return res
67+
68+
69+
class TestDropout(UnittestBase):
70+
def init_info(self):
71+
self.shapes = [[10, 10]]
72+
self.save_path = os.path.join(self.temp_dir.name, 'dropout')
73+
74+
def test_static(self):
75+
main_prog = Program()
76+
startup_prog = Program()
77+
with program_guard(main_prog, startup_prog):
78+
fc = paddle.nn.Linear(10, 10)
79+
x = paddle.randn(self.shapes[0])
80+
x.stop_gradient = False
81+
feat = fc(x)
82+
# p is a Variable
83+
p = paddle.randn([1])
84+
out = paddle.nn.functional.dropout(feat, p=p)
85+
sgd = paddle.optimizer.SGD()
86+
sgd.minimize(paddle.mean(out))
87+
# test _to_string
88+
self.assertTrue("Var[" in str(main_prog))
89+
90+
exe = paddle.static.Executor()
91+
exe.run(startup_prog)
92+
res = exe.run(fetch_list=[x, out])
93+
# export model
94+
paddle.static.save_inference_model(self.save_path, [x], [out], exe)
95+
96+
# Test for Inference Predictor
97+
infer_out = self.infer_prog()
98+
self.assertEqual(infer_out.shape, (10, 10))
99+
100+
self.assertEqual(
101+
main_prog.block(0).ops[4].all_attrs()['dropout_prob'].name,
102+
p.name,
103+
)
104+
105+
106+
if __name__ == '__main__':
107+
unittest.main()

test/deprecated/legacy_test/test_eye_op.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import numpy as np
1919
from op_test import OpTest
20-
from test_attribute_var import UnittestBase
20+
from test_attribute_var_deprecated import UnittestBase
2121

2222
import paddle
2323
from paddle import base

test/deprecated/legacy_test/test_multinomial_op.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import numpy as np
1919
from op_test import OpTest, convert_float_to_uint16
20-
from test_attribute_var import UnittestBase
20+
from test_attribute_var_deprecated import UnittestBase
2121

2222
import paddle
2323
from paddle import base

0 commit comments

Comments
 (0)