From 3af238f4f719e3a9b998447550aa1ad9084201ae Mon Sep 17 00:00:00 2001 From: kangguangli Date: Thu, 21 Dec 2023 09:03:26 +0000 Subject: [PATCH 1/8] fix property overwrite --- test/CMakeLists.txt | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a61b75dd75af43..e3e96e9aaf2573 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -96,8 +96,13 @@ function(set_pit_tests_properties) PIR_OP_TESTS) foreach(IR_OP_TEST ${PIR_OP_TESTS}) if(TEST ${IR_OP_TEST}) - set_tests_properties( - ${IR_OP_TEST} PROPERTIES ENVIRONMENT "FLAGS_PIR_OPTEST_WHITE_LIST=True") + set_property( + TEST ${IR_OP_TEST} + APPEND + PROPERTY ENVIRONMENT "FLAGS_PIR_OPTEST_WHITE_LIST=True") + message(STATUS "PIR OpTest: succ set ${IR_OP_TEST}") + else() + message(STATUS "PIR OpTest: not found ${IR_OP_TEST}") endif() endforeach() @@ -105,8 +110,13 @@ function(set_pit_tests_properties) PIR_OP_NO_CHECK_TESTS) foreach(IR_OP_TEST ${PIR_OP_NO_CHECK_TESTS}) if(TEST ${IR_OP_TEST}) - set_tests_properties(${IR_OP_TEST} PROPERTIES ENVIRONMENT - "FLAGS_PIR_NO_CHECK=True") + set_property( + TEST ${IR_OP_TEST} + APPEND + PROPERTY ENVIRONMENT "FLAGS_PIR_NO_CHECK=True") + message(STATUS "PIR OpTest: succ set ${IR_OP_TEST}") + else() + message(STATUS "PIR OpTest: not found ${IR_OP_TEST}") endif() endforeach() @@ -115,9 +125,13 @@ function(set_pit_tests_properties) PIR_OP_RELAXED_TESTS) foreach(IR_OP_TEST ${PIR_OP_RELAXED_TESTS}) if(TEST ${IR_OP_TEST}) - set_tests_properties( - ${IR_OP_TEST} PROPERTIES ENVIRONMENT - "FLAGS_PIR_OPTEST_RELAX_CHECK=True") + set_property( + TEST ${IR_OP_TEST} + APPEND + PROPERTY ENVIRONMENT "FLAGS_PIR_OPTEST_RELAX_CHECK=True") + message(STATUS "PIR OpTest: succ set ${IR_OP_TEST}") + else() + message(STATUS "PIR OpTest: not found ${IR_OP_TEST}") endif() endforeach() From b30788f14ef209366224b3a7882f25df75cbad8e Mon Sep 17 00:00:00 2001 From: kangguangli Date: Thu, 21 Dec 2023 11:00:28 +0000 Subject: [PATCH 2/8] fix op test --- test/legacy_test/op_test.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/legacy_test/op_test.py b/test/legacy_test/op_test.py index 2222638fb339bd..a72aa1d9716a0d 100644 --- a/test/legacy_test/op_test.py +++ b/test/legacy_test/op_test.py @@ -1489,8 +1489,8 @@ def _check_ir_output(self, place, program, feed_map, fetch_list, outs): check_method = np.testing.assert_array_equal if os.getenv("FLAGS_PIR_OPTEST_RELAX_CHECK", None) == "True": - check_method = lambda x, y, z: np.testing.assert_allclose( - x, y, err_msg=z, atol=1e-6, rtol=1e-6 + check_method = lambda x, y, err_msg: np.testing.assert_allclose( + x, y, err_msg=err_msg, atol=1e-6, rtol=1e-6 ) if os.getenv("FLAGS_PIR_NO_CHECK", None) == "True": check_method = lambda x, y, err_msg: None From b80345f7b6cc5b049899f866c5f3a06765f4a264 Mon Sep 17 00:00:00 2001 From: kangguangli Date: Thu, 21 Dec 2023 13:02:36 +0000 Subject: [PATCH 3/8] fix op test --- test/legacy_test/op_test.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/legacy_test/op_test.py b/test/legacy_test/op_test.py index a72aa1d9716a0d..1431ff801ba901 100644 --- a/test/legacy_test/op_test.py +++ b/test/legacy_test/op_test.py @@ -1489,9 +1489,13 @@ def _check_ir_output(self, place, program, feed_map, fetch_list, outs): check_method = np.testing.assert_array_equal if os.getenv("FLAGS_PIR_OPTEST_RELAX_CHECK", None) == "True": - check_method = lambda x, y, err_msg: np.testing.assert_allclose( - x, y, err_msg=err_msg, atol=1e-6, rtol=1e-6 - ) + + def relaxed_check(x, y, err_msg=""): + np.testing.assert_allclose( + x, y, err_msg=err_msg, atol=1e-6, rtol=1e-6 + ) + + check_method = relaxed_check if os.getenv("FLAGS_PIR_NO_CHECK", None) == "True": check_method = lambda x, y, err_msg: None From 3d6f8112e34c129d785cc8e86ffd4f2222d2f0c0 Mon Sep 17 00:00:00 2001 From: kangguangli Date: Fri, 22 Dec 2023 03:29:25 +0000 Subject: [PATCH 4/8] fix op test --- test/legacy_test/op_test.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/legacy_test/op_test.py b/test/legacy_test/op_test.py index 1431ff801ba901..d62791e168ee7a 100644 --- a/test/legacy_test/op_test.py +++ b/test/legacy_test/op_test.py @@ -3541,12 +3541,20 @@ def _check_ir_grad_output( check_method = np.testing.assert_array_equal if os.getenv("FLAGS_PIR_OPTEST_RELAX_CHECK", None) == "True": - check_method = lambda x, y, z: np.testing.assert_allclose( - x, y, err_msg=z, atol=1e-6, rtol=1e-6 - ) + + def relaxed_check_method(x, y, err_msg): + np.testing.assert_allclose( + x, y, err_msg=err_msg, atol=1e-6, rtol=1e-6 + ) + + check_method = relaxed_check_method if os.getenv("FLAGS_PIR_NO_CHECK", None) == "True": - check_method = lambda x, y, err_msg: None + + def no_check_method(x, y, err_msg): + pass + + check_method = no_check_method for i in range(len(new_gradients)): check_method( From 2c65ea7cca303146351c1cda8100da1785a0c450 Mon Sep 17 00:00:00 2001 From: kangguangli Date: Fri, 22 Dec 2023 07:18:27 +0000 Subject: [PATCH 5/8] fix op test --- test/legacy_test/op_test.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/legacy_test/op_test.py b/test/legacy_test/op_test.py index d62791e168ee7a..8510e24a3b8553 100644 --- a/test/legacy_test/op_test.py +++ b/test/legacy_test/op_test.py @@ -3543,8 +3543,13 @@ def _check_ir_grad_output( if os.getenv("FLAGS_PIR_OPTEST_RELAX_CHECK", None) == "True": def relaxed_check_method(x, y, err_msg): + atol = 1e-6 + rtol = 1e-6 + if x.dtype == np.float16: + atol = 1e-5 + rtol = 1e-3 np.testing.assert_allclose( - x, y, err_msg=err_msg, atol=1e-6, rtol=1e-6 + x, y, err_msg=err_msg, atol=atol, rtol=rtol ) check_method = relaxed_check_method From 663678b8adb37b292852aaec9c19bef447952f1f Mon Sep 17 00:00:00 2001 From: kangguangli Date: Mon, 25 Dec 2023 03:26:16 +0000 Subject: [PATCH 6/8] remove unit test --- test/white_list/pir_op_test_white_list | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/white_list/pir_op_test_white_list b/test/white_list/pir_op_test_white_list index c00f7fba976985..2517fe1bee4b8e 100644 --- a/test/white_list/pir_op_test_white_list +++ b/test/white_list/pir_op_test_white_list @@ -6,10 +6,7 @@ test_adadelta_op test_adagrad_op test_adagrad_op_static_build test_adamax_op -test_adamw_op -test_adamw_op_static_build test_addmm_op -test_affine_grid_op test_allclose_op test_amp_check_finite_and_scale_op test_angle_op @@ -60,7 +57,6 @@ test_conv2d_bf16_mkldnn_op test_conv2d_int8_mkldnn_op test_conv2d_mkldnn_op test_conv2d_op -test_conv2d_op_depthwise_conv test_conv2d_transpose_bf16_mkldnn_op test_conv2d_transpose_mkldnn_op test_conv2d_transpose_op @@ -232,7 +228,6 @@ test_polygamma_op test_pool2d_int8_mkldnn_op test_pool2d_mkldnn_op test_pool2d_op -test_pool3d_op test_pool_max_op test_prelu_mkldnn_op test_prelu_op From a98b4cf65f7e7f4f65b50b4105066fa25b9f5f39 Mon Sep 17 00:00:00 2001 From: kangguangli Date: Mon, 25 Dec 2023 07:18:25 +0000 Subject: [PATCH 7/8] remove debug messages --- test/CMakeLists.txt | 9 --------- 1 file changed, 9 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e3e96e9aaf2573..fd305ce6e89557 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -100,9 +100,6 @@ function(set_pit_tests_properties) TEST ${IR_OP_TEST} APPEND PROPERTY ENVIRONMENT "FLAGS_PIR_OPTEST_WHITE_LIST=True") - message(STATUS "PIR OpTest: succ set ${IR_OP_TEST}") - else() - message(STATUS "PIR OpTest: not found ${IR_OP_TEST}") endif() endforeach() @@ -114,9 +111,6 @@ function(set_pit_tests_properties) TEST ${IR_OP_TEST} APPEND PROPERTY ENVIRONMENT "FLAGS_PIR_NO_CHECK=True") - message(STATUS "PIR OpTest: succ set ${IR_OP_TEST}") - else() - message(STATUS "PIR OpTest: not found ${IR_OP_TEST}") endif() endforeach() @@ -129,9 +123,6 @@ function(set_pit_tests_properties) TEST ${IR_OP_TEST} APPEND PROPERTY ENVIRONMENT "FLAGS_PIR_OPTEST_RELAX_CHECK=True") - message(STATUS "PIR OpTest: succ set ${IR_OP_TEST}") - else() - message(STATUS "PIR OpTest: not found ${IR_OP_TEST}") endif() endforeach() From 6aa9856d74929857f9c5c20df7ce74977de28295 Mon Sep 17 00:00:00 2001 From: kangguangli Date: Mon, 25 Dec 2023 11:19:50 +0000 Subject: [PATCH 8/8] remove unit test --- test/white_list/pir_op_test_white_list | 1 - 1 file changed, 1 deletion(-) diff --git a/test/white_list/pir_op_test_white_list b/test/white_list/pir_op_test_white_list index 2517fe1bee4b8e..2a18a51e577caa 100644 --- a/test/white_list/pir_op_test_white_list +++ b/test/white_list/pir_op_test_white_list @@ -63,7 +63,6 @@ test_conv2d_transpose_op test_conv2d_transpose_op_depthwise_conv test_conv3d_mkldnn_op test_conv3d_op -test_conv3d_transpose_op test_conv3d_transpose_part2_op test_crop_tensor_op test_cross_op