From b852ef7375cc6bcddf7441b97eb3c39477080801 Mon Sep 17 00:00:00 2001 From: Pei Yang Date: Thu, 2 Jan 2020 15:11:17 +0800 Subject: [PATCH] add no_check_set check for op unittests (#21611) --- .../paddle/fluid/tests/unittests/op_test.py | 6 ++++- .../white_list/no_check_set_white_list.py | 26 +++++++++++++++++++ tools/check_api_approvals.sh | 4 +++ 3 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 python/paddle/fluid/tests/unittests/white_list/no_check_set_white_list.py diff --git a/python/paddle/fluid/tests/unittests/op_test.py b/python/paddle/fluid/tests/unittests/op_test.py index bebfaf3804f..8ab0f9b825a 100644 --- a/python/paddle/fluid/tests/unittests/op_test.py +++ b/python/paddle/fluid/tests/unittests/op_test.py @@ -33,7 +33,7 @@ from paddle.fluid.executor import Executor from paddle.fluid.framework import Program, OpProtoHolder, Variable from testsuite import create_op, set_input, append_input_output, append_loss_ops from paddle.fluid import unique_name -from white_list import op_accuracy_white_list, check_shape_white_list, compile_vs_runtime_white_list +from white_list import op_accuracy_white_list, check_shape_white_list, compile_vs_runtime_white_list, no_check_set_white_list def _set_use_system_allocator(value=None): @@ -903,6 +903,10 @@ class OpTest(unittest.TestCase): equal_nan=False, check_dygraph=True, inplace_atol=None): + if no_check_set is not None: + if self.op_type not in no_check_set_white_list.no_check_set_white_list: + raise AssertionError( + "no_check_set of op %s must be set to None." % self.op_type) if check_dygraph: dygraph_outs = self._calc_dygraph_output( place, no_check_set=no_check_set) diff --git a/python/paddle/fluid/tests/unittests/white_list/no_check_set_white_list.py b/python/paddle/fluid/tests/unittests/white_list/no_check_set_white_list.py new file mode 100644 index 00000000000..e58c3834e32 --- /dev/null +++ b/python/paddle/fluid/tests/unittests/white_list/no_check_set_white_list.py @@ -0,0 +1,26 @@ +# Copyright (c) 2019 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. + +# no_check_set of check_output must be None +no_check_set_white_list = [ + 'fake_quantize_range_abs_max', + 'coalesce_tensor', + 'flatten2', + 'squeeze2', + 'reshape2', + 'transpose2', + 'unsqueeze2', + 'cross_entropy2', + 'seed', +] diff --git a/tools/check_api_approvals.sh b/tools/check_api_approvals.sh index b9a5f6ce8f3..d78950970a1 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/no_check_set_white_list.py" ) approval_line=`curl -H "Authorization: token ${GITHUB_API_TOKEN}" https://api.github.com/repos/PaddlePaddle/Paddle/pulls/${GIT_PR_ID}/reviews?per_page=10000` @@ -114,6 +115,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/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 else echo_line="You must have one RD (XiaoguangHu01,Xreki,luotao1,sneaxiy) approval for ${API_FILE}, which manages the underlying code for fluid.\n" check_approval 1 3048612 46782768 12538138 6836917 32832641 -- GitLab