diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index 6a85aeb4c52848df41bbcb5540665c8e75a564ba..f63e580e617cc09c88d4350a320f9fffa7febb8c 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -567,6 +567,10 @@ function check_change_of_unittest() { check_approvals_of_unittest 2 } +function check_sequence_op_unittest(){ + /bin/bash ${PADDLE_ROOT}/tools/check_sequence_op.sh +} + function generate_unittest_spec() { spec_kind=$1 if [ "$spec_kind" == "DEV" ]; then @@ -1122,7 +1126,8 @@ function main() { cmake_gen ${PYTHON_ABI:-""} build ${parallel_number} example - generate_api_spec ${PYTHON_ABI:-""} "PR" + check_sequence_op_unittest + generate_api_spec ${PYTHON_ABI:-""} "PR" assert_api_spec_approvals ;; build) diff --git a/python/paddle/fluid/tests/unittests/white_list/check_op_sequence_batch_1_input_white_list.py b/python/paddle/fluid/tests/unittests/white_list/check_op_sequence_batch_1_input_white_list.py new file mode 100644 index 0000000000000000000000000000000000000000..3d38ec8a4f416a34f346e810cb75e1a85ad094b9 --- /dev/null +++ b/python/paddle/fluid/tests/unittests/white_list/check_op_sequence_batch_1_input_white_list.py @@ -0,0 +1,39 @@ +# Copyright (c) 2020 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. + +from __future__ import print_function +import sys + +# For ops in this whitelist, the check of batch size = 1 input will be skipped. +# Ops in this whitelist need to be fixed later. +NEED_TO_FIX_OP_LIST = [ + 'sequence_concat', + 'sequence_conv', + 'sequence_enumerate', + 'sequence_erase', + 'sequence_expand_as', + 'sequence_expand', + 'sequence_mask', + 'sequence_pad', + 'sequence_reshape', + 'sequence_reverse', + 'sequence_scatter', + 'sequence_slice', + 'sequence_softmax', + 'sequence_topk_avg_pooling', + 'sequence_unpad', +] + +op_name = sys.argv[1] +print(op_name in NEED_TO_FIX_OP_LIST) diff --git a/tools/check_api_approvals.sh b/tools/check_api_approvals.sh index a58aa6b9e1bb8ad9acf9bef126a0ce985070c055..a8eff9b2283cdb0392ff48d6ec4b8a78d0370076 100644 --- a/tools/check_api_approvals.sh +++ b/tools/check_api_approvals.sh @@ -32,6 +32,7 @@ API_FILES=("CMakeLists.txt" "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" "python/paddle/fluid/tests/unittests/white_list/op_threshold_white_list.py" + "python/paddle/fluid/tests/unittests/white_list/check_op_sequence_batch_1_input_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` @@ -53,7 +54,7 @@ function check_approval(){ function add_failed(){ failed_num=`expr $failed_num + 1` echo_list="${echo_list[@]}$1" -} +} if [[ $git_files -gt 19 || $git_count -gt 999 ]];then @@ -126,6 +127,9 @@ for API_FILE in ${API_FILES[*]}; do elif [ "${API_FILE}" == "python/paddle/fluid/tests/unittests/white_list/op_threshold_white_list.py" ];then echo_line="It is an Op accuracy problem, please take care of it. You must have one RD (juncaipeng (Recommend), zhangting2020 or luotao1) approval for the python/paddle/fluid/tests/unittests/white_list/op_threshold_white_list.py, which manages the white list of error threshold for op test with float64 precision. 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/check_op_sequence_batch_1_input_white_list.py" ];then + echo_line="You must have one RD (songyouwei, luotao1 or phlrain) approval for ${API_FILE}, which manages the white list of batch size 1 input for sequence op test. For more information, please refer to [https://github.com/PaddlePaddle/Paddle/wiki/It-is-required-to-include-LoDTensor-input-with-batch_size=1-in-sequence-OP-test]. \n" + check_approval 1 2573291 6836917 43953930 else echo_line="It is an Op accuracy problem, please take care of it. 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 diff --git a/tools/check_sequence_op.sh b/tools/check_sequence_op.sh new file mode 100644 index 0000000000000000000000000000000000000000..9abf8e604a47e58c08b1ba9c18acc0e2489b3b40 --- /dev/null +++ b/tools/check_sequence_op.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +PADDLE_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}")/../" && pwd )" + +function check_sequnece_op_unitests(){ + check_white_list_file=$1 + function_grep=$2 + INVALID_SEQUENCE_OP_UNITTEST="" + all_sequence_ops=`grep '(sequence_' ${PADDLE_ROOT}/build/paddle/fluid/pybind/pybind.h | grep -Ev '^$' | cut -d'(' -f 2 | cut -d')' -f 1` + for op_name in ${all_sequence_ops}; do + in_white_list=`python ${PADDLE_ROOT}/${check_white_list_file} ${op_name}` + if [ "${in_white_list}" == "True" ]; then + continue + fi + unittest_file="python/paddle/fluid/tests/unittests/sequence/test_${op_name}.py" + if [ ! -f "${PADDLE_ROOT}/${unittest_file}" ]; then + INVALID_SEQUENCE_OP_UNITTEST="${INVALID_SEQUENCE_OP_UNITTEST}${unittest_file} (unittest file does not exists)\n" + continue + fi + batch_size_1_funtion_calls=`grep ${function_grep} ${PADDLE_ROOT}/${unittest_file} || true` + if [ "${batch_size_1_funtion_calls}" == "" ]; then + INVALID_SEQUENCE_OP_UNITTEST="${INVALID_SEQUENCE_OP_UNITTEST}${unittest_file} (missing required function call)\n" + fi + done + echo ${INVALID_SEQUENCE_OP_UNITTEST} +} + +check_white_list_file="python/paddle/fluid/tests/unittests/white_list/check_op_sequence_batch_1_input_white_list.py" +function_grep="self.get_sequence_batch_size_1_input(" +INVALID_SEQUENCE_OP_UNITTEST=$(check_sequnece_op_unitests ${check_white_list_file} ${function_grep}) +if [ "${INVALID_SEQUENCE_OP_UNITTEST}" != "" ]; then + echo "************************************" + echo -e "It is required to include batch size 1 LoDTensor input in sequence OP test, please use self.get_sequence_batch_size_1_input() method." + echo -e "For more information, please refer to [https://github.com/PaddlePaddle/Paddle/wiki/It-is-required-to-include-LoDTensor-input-with-batch_size=1-in-sequence-OP-test]." + echo -e "Please check the following unittest files:\n${INVALID_SEQUENCE_OP_UNITTEST}" + echo "************************************" + exit 1 +fi