From 8f6446d3d98418677f79e239e0e6d4214fb7aec6 Mon Sep 17 00:00:00 2001 From: kangguangli Date: Mon, 14 Aug 2023 11:19:41 +0800 Subject: [PATCH] [NewIR]test new ir op test in gpu (#55857) * add ir output check in OpTest * add ir grad check in op test * fix bug in output check * trigger CI * test gpu ci * trigger CI * trigger CI * add white list to relax precision check for some tests * relax timeout of test_concat_op * relax timeout of test_concat_op --- paddle/scripts/paddle_build.sh | 1 + test/legacy_test/CMakeLists.txt | 18 ++++++++++++++++-- test/legacy_test/eager_op_test.py | 17 +++++++++++++++-- .../new_ir_op_test_precision_white_list | 17 +++++++++++++++++ 4 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 test/white_list/new_ir_op_test_precision_white_list diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index 2513f5ec0d5..5a665db8ba9 100644 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -3972,6 +3972,7 @@ function main() { check_coverage_build ;; gpu_cicheck_coverage) + export FLAGS_NEW_IR_OPTEST=True parallel_test check_coverage ;; diff --git a/test/legacy_test/CMakeLists.txt b/test/legacy_test/CMakeLists.txt index f8694e6bfaa..a374a36102d 100644 --- a/test/legacy_test/CMakeLists.txt +++ b/test/legacy_test/CMakeLists.txt @@ -967,10 +967,10 @@ if(WITH_NV_JETSON) set_tests_properties(test_layer_norm_op PROPERTIES TIMEOUT 1500) set_tests_properties(test_pool3d_op PROPERTIES TIMEOUT 1500) else() - set_tests_properties(test_concat_op PROPERTIES TIMEOUT 120) + set_tests_properties(test_concat_op PROPERTIES TIMEOUT 240) set_tests_properties(test_conv3d_transpose_part2_op PROPERTIES TIMEOUT 120) set_tests_properties(test_conv3d_op PROPERTIES TIMEOUT 120) - set_tests_properties(test_norm_op PROPERTIES TIMEOUT 120) + set_tests_properties(test_norm_op PROPERTIES TIMEOUT 150) set_tests_properties(test_batch_norm_op_prim_nchw PROPERTIES TIMEOUT 250) set_tests_properties(test_batch_norm_op_prim_nhwc PROPERTIES TIMEOUT 250) set_tests_properties(test_layer_norm_op PROPERTIES TIMEOUT 250) @@ -1378,6 +1378,20 @@ foreach(IR_OP_TEST ${NEW_IR_OP_TESTS}) endif() endforeach() +file(STRINGS + "${CMAKE_SOURCE_DIR}/test/white_list/new_ir_op_test_precision_white_list" + NEW_IR_OP_RELAXED_TESTS) +foreach(IR_OP_TEST ${NEW_IR_OP_RELAXED_TESTS}) + if(TEST ${IR_OP_TEST}) + set_tests_properties( + ${IR_OP_TEST} PROPERTIES ENVIRONMENT + "FLAGS_NEW_IR_OPTEST_RELAX_CHECK=True") + else() + message( + STATUS "NewIR Relaxed OpTest: not found ${IR_OP_TEST} in legacy_test") + endif() +endforeach() + set(STRIED_TESTS test_complex_getitem test_complex_grad_accumulated diff --git a/test/legacy_test/eager_op_test.py b/test/legacy_test/eager_op_test.py index c15fcb051e3..c8b7ec70b70 100644 --- a/test/legacy_test/eager_op_test.py +++ b/test/legacy_test/eager_op_test.py @@ -1232,8 +1232,15 @@ class OpTest(unittest.TestCase): assert len(outs) == len( ir_outs ), "Fetch result should have same length when executed in new ir" + + check_method = np.testing.assert_array_equal + if os.getenv("FLAGS_NEW_IR_OPTEST_RELAX_CHECK", None): + check_method = lambda x, y, z: np.testing.assert_allclose( + x, y, err_msg=z, atol=1e-6, rtol=1e-6 + ) + for i in range(len(outs)): - np.testing.assert_array_equal( + check_method( outs[i], ir_outs[i], err_msg='Operator Check (' @@ -2915,8 +2922,14 @@ class OpTest(unittest.TestCase): ) ) + check_method = np.testing.assert_array_equal + if os.getenv("FLAGS_NEW_IR_OPTEST_RELAX_CHECK", None): + check_method = lambda x, y, z: np.testing.assert_allclose( + x, y, err_msg=z, atol=1e-6, rtol=1e-6 + ) + for i in range(len(new_gradients)): - np.testing.assert_array_equal( + check_method( gradients[i], new_gradients[i], err_msg='Operator GradCheck (' diff --git a/test/white_list/new_ir_op_test_precision_white_list b/test/white_list/new_ir_op_test_precision_white_list new file mode 100644 index 00000000000..34f439e3299 --- /dev/null +++ b/test/white_list/new_ir_op_test_precision_white_list @@ -0,0 +1,17 @@ +test_affine_grid_op +test_bicubic_interp_v2_op +test_conv2d_op +test_conv2d_op_depthwise_conv +test_conv2d_transpose_op +test_conv2d_transpose_op_depthwise_conv +test_conv3d_op +test_conv3d_transpose_op +test_conv3d_transpose_part2_op +test_deformable_conv_op +test_graph_send_recv_op +test_graph_send_ue_recv_op +test_grid_sampler_op +test_group_norm_op +test_pool2d_op +test_pool3d_op +test_trilinear_interp_v2_op -- GitLab