From f5f65a7e8ac9e1142f5dbb596a77cc4387acb871 Mon Sep 17 00:00:00 2001 From: huzhiqiang <912790387@qq.com> Date: Fri, 3 Jan 2020 11:23:30 +0800 Subject: [PATCH] OP unit test specification: compiletime-runtime consistency check (#22006) --- python/paddle/fluid/tests/unittests/op_test.py | 7 ++----- .../tests/unittests/sequence/test_sequence_pad_op.py | 2 +- .../unittests/sequence/test_sequence_unpad_op.py | 2 +- .../tests/unittests/test_match_matrix_tensor_op.py | 2 +- .../white_list/compile_vs_runtime_white_list.py | 4 +++- tools/check_api_approvals.sh | 11 ++++------- 6 files changed, 12 insertions(+), 16 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/op_test.py b/python/paddle/fluid/tests/unittests/op_test.py index 8ab0f9b825..5006a8cf3b 100644 --- a/python/paddle/fluid/tests/unittests/op_test.py +++ b/python/paddle/fluid/tests/unittests/op_test.py @@ -1118,8 +1118,7 @@ class OpTest(unittest.TestCase): no_check_set=None, equal_nan=False, check_dygraph=True, - inplace_atol=None, - check_compile_vs_runtime=True): + inplace_atol=None): self.__class__.op_type = self.op_type if hasattr(self, "use_mkldnn"): self.__class__.use_mkldnn = self.use_mkldnn @@ -1131,9 +1130,7 @@ class OpTest(unittest.TestCase): outs, dygraph_outs, fetch_list = res else: outs, fetch_list = res - if check_compile_vs_runtime and ( - self.op_type not in - compile_vs_runtime_white_list.COMPILE_RUN_OP_WHITE_LIST): + if self.op_type not in compile_vs_runtime_white_list.COMPILE_RUN_OP_WHITE_LIST: self.check_compile_vs_runtime(fetch_list, outs) def check_output_customized(self, checker): diff --git a/python/paddle/fluid/tests/unittests/sequence/test_sequence_pad_op.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_pad_op.py index a710fc5ce8..83c28edd23 100644 --- a/python/paddle/fluid/tests/unittests/sequence/test_sequence_pad_op.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_pad_op.py @@ -74,7 +74,7 @@ class TestSequencePadOp(OpTest): self.compute() def test_check_output(self): - self.check_output(check_compile_vs_runtime=True, check_dygraph=False) + self.check_output(check_dygraph=False) def test_check_grad(self): self.check_grad(["X"], "Out", check_dygraph=False) diff --git a/python/paddle/fluid/tests/unittests/sequence/test_sequence_unpad_op.py b/python/paddle/fluid/tests/unittests/sequence/test_sequence_unpad_op.py index a37f7b58ee..458088b4f5 100644 --- a/python/paddle/fluid/tests/unittests/sequence/test_sequence_unpad_op.py +++ b/python/paddle/fluid/tests/unittests/sequence/test_sequence_unpad_op.py @@ -50,7 +50,7 @@ class TestSequenceUnpadOp(OpTest): self.compute() def test_check_output(self): - self.check_output(check_compile_vs_runtime=True, check_dygraph=False) + self.check_output(check_dygraph=False) def test_check_grad(self): self.check_grad(["X"], "Out", check_dygraph=False) diff --git a/python/paddle/fluid/tests/unittests/test_match_matrix_tensor_op.py b/python/paddle/fluid/tests/unittests/test_match_matrix_tensor_op.py index e8acd1cd3b..9306b76689 100644 --- a/python/paddle/fluid/tests/unittests/test_match_matrix_tensor_op.py +++ b/python/paddle/fluid/tests/unittests/test_match_matrix_tensor_op.py @@ -71,7 +71,7 @@ class TestMatchMatrixTensorOp(OpTest): self.outputs = {'Out': (out, out_lod), 'Tmp': tmp} def test_check_output(self): - self.check_output(check_compile_vs_runtime=True, check_dygraph=False) + self.check_output(check_dygraph=False) def test_check_grad(self): self.check_grad(['X', 'Y'], 'Out', check_dygraph=False) diff --git a/python/paddle/fluid/tests/unittests/white_list/compile_vs_runtime_white_list.py b/python/paddle/fluid/tests/unittests/white_list/compile_vs_runtime_white_list.py index c7184633f1..1958e90ad1 100644 --- a/python/paddle/fluid/tests/unittests/white_list/compile_vs_runtime_white_list.py +++ b/python/paddle/fluid/tests/unittests/white_list/compile_vs_runtime_white_list.py @@ -15,7 +15,9 @@ # If the output after infershape() is a lod_tensor, commenly its lod_level # should be equal during compile time and run time. # For ops in this whitelist, the equality check of lod_level between -# compiletime&runtime will not be required. +# compiletime&runtime will be skipped. Ops in this whitelist need to declear +# reasons for skipping compile_vs_runtime test or be fixed later. + COMPILE_RUN_OP_WHITE_LIST = [ 'lod_reset', 'sequence_pool', 'sequence_slice', 'generate_mask_labels', 'sequence_reshape', 'generate_proposals', 'mine_hard_examples', diff --git a/tools/check_api_approvals.sh b/tools/check_api_approvals.sh index d78950970a..49db061700 100644 --- a/tools/check_api_approvals.sh +++ b/tools/check_api_approvals.sh @@ -29,6 +29,7 @@ API_FILES=("CMakeLists.txt" "paddle/fluid/framework/unused_var_check.cc" "python/paddle/fluid/tests/unittests/white_list/check_shape_white_list.py" "python/paddle/fluid/tests/unittests/white_list/op_accuracy_white_list.py" + "python/paddle/fluid/tests/unittests/white_list/compile_vs_runtime_white_list.py" "python/paddle/fluid/tests/unittests/white_list/no_check_set_white_list.py" ) @@ -115,6 +116,9 @@ for API_FILE in ${API_FILES[*]}; do elif [ "${API_FILE}" == "python/paddle/fluid/tests/unittests/white_list/op_accuracy_white_list.py" ];then echo_line="You must have one RD (juncaipeng (Recommend), zhangting2020 (Recommend) or luotao1) approval for the python/paddle/fluid/tests/unittests/white_list/op_accuracy_white_list.py, which manages the white list of upgrading the precision of op test to float64. For more information, please refer to: https://github.com/PaddlePaddle/Paddle/wiki/Upgrade-OP-Precision-to-Float64. \n" check_approval 1 52520497 26615455 6836917 + elif [ "${API_FILE}" == "python/paddle/fluid/tests/unittests/white_list/compile_vs_runtime_white_list.py" ];then + echo_line="You must have one RD (DannyIsFunny (Recommend), luotao1, phlrain) approval for the python/paddle/fluid/tests/unittests/white_list/compile_vs_runtime_white_list.py, which manages the white list of compile&runtime lod-level check. For more information, please refer to: https://github.com/PaddlePaddle/Paddle/wiki/Compile_vs_Runtime-Check-Specification. \n" + check_approval 1 45189361 6836917 43953930 elif [ "${API_FILE}" == "python/paddle/fluid/tests/unittests/white_list/no_check_set_white_list.py" ];then echo_line="You must have one RD (cryoco (Recommend), luotao1 or phlrain) approval for the python/paddle/fluid/tests/unittests/white_list/no_check_set_white_list.py, which manages the white list of setting no_check_set of check_output. \n" check_approval 1 12407750 26615455 6836917 @@ -179,13 +183,6 @@ if [ "${HAS_INPLACE_TESTS}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then check_approval 1 46782768 47554610 43953930 6836917 fi -HAS_COMPILERUNTIME_NOT_TEST=`git diff -U0 --diff-filter=A upstream/$BRANCH |grep "+" |grep -E "check_output[(]*check_compile_vs_runtime=False" || true` -if [ "${HAS_COMPILERUNTIME_NOT_TEST}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then - echo_line="If the operator's output after infershape() is a LodTensor, the output's Lod-Level during compile-time and runtime must be equal. Please set check_compile_vs_runtime=True in op_test.check_output function to enable compile&runtime lod-level check.\n -If you do not need check_compile_vs_runtime, you must have one RD (lanxianghit, phlrain, luotao1) approval.\nThe corresponding lines are as follows:\n${HAS_COMPILERUNTIME_NOT_TEST}\n" - check_approval 1 47554610 43953930 6836917 -fi - OP_FILE_CHANGED=`git diff --name-only --diff-filter=AMR upstream/$BRANCH |grep -oE ".+_op..*" || true` if [ "${OP_FILE_CHANGED}" != "" ] && [ "${GIT_PR_ID}" != "" ]; then for OP_FILE in ${OP_FILE_CHANGED}; -- GitLab