From 666da145c2b6506d483d7155b52e131d53c3b599 Mon Sep 17 00:00:00 2001 From: Qi Li Date: Mon, 13 Sep 2021 12:23:48 +0800 Subject: [PATCH] [NPU] add npu unit test if title has NPU key word, test=develop (#35566) --- paddle/fluid/operators/stack_op_npu.cc | 4 ++-- paddle/scripts/paddle_build.sh | 17 ++++++++++------- .../fluid/tests/unittests/npu/CMakeLists.txt | 5 +++++ 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/paddle/fluid/operators/stack_op_npu.cc b/paddle/fluid/operators/stack_op_npu.cc index c6c54b7d81..d2ece1da36 100644 --- a/paddle/fluid/operators/stack_op_npu.cc +++ b/paddle/fluid/operators/stack_op_npu.cc @@ -90,9 +90,9 @@ REGISTER_OP_NPU_KERNEL( paddle::operators::StackNPUKernel); REGISTER_OP_NPU_KERNEL( - stack_grad, paddle::operators::StackNPUKernel, + stack_grad, paddle::operators::StackGradNPUKernel, #ifdef PADDLE_WITH_ASCEND_INT64 - paddle::operators::StackNPUKernel, + paddle::operators::StackGradNPUKernel, #endif paddle::operators::StackGradNPUKernel, paddle::operators::StackGradNPUKernel); diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index a3f98ea511..b0aca00071 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -1746,11 +1746,14 @@ function parallel_test_base_npu() { # skipping if no NPU related files changed if [ ${SKIP_NPU_TEST:-ON} == "ON" ] ; then fetch_upstream_develop_if_not_exist + # get npu py or npu cc file changes git diff --name-only remotes/upstream/$BRANCH npu_cc_changes=$(git diff --name-only remotes/upstream/$BRANCH | grep "op_npu.cc" || true) npu_py_changes=$(git diff --name-only remotes/upstream/$BRANCH | grep "op_npu.py" || true) - if [ -z "${npu_cc_changes}" ] && [ -z "${npu_py_changes}" ] ; then - echo "NO NPU operators files changed, skip NPU unit tests!" + # get PR name + npu_pr_tile=$(curl https://github.com/PaddlePaddle/Paddle/pull/${GIT_PR_ID} 2>/dev/null | grep "" | grep "[NPU]" || true) + if [ -z "${npu_cc_changes}" ] && [ -z "${npu_py_changes}" ] && [ -z "${npu_pr_tile}" ]; then + echo "NO NPU operators files changed and no '[NPU]' found in PR title, skip NPU unit tests!" exit 0 fi fi @@ -1797,10 +1800,10 @@ set +x if [ ${TIMEOUT_DEBUG_HELP:-OFF} == "ON" ];then bash $PADDLE_ROOT/tools/timeout_debug_help.sh "$failed_test_lists" # cat logs for tiemout uts which killed by ctest fi - read need_retry_ut_str <<< $(echo "$failed_test_lists" | grep -oEi "\-.+\(.+\)" | sed 's/(.\+)//' | sed 's/- //' ) + need_retry_ut_str=$(echo "$failed_test_lists" | grep -oEi "\-.+\(.+\)" | sed 's/(.\+)//' | sed 's/- //' ) need_retry_ut_arr=(${need_retry_ut_str}) need_retry_ut_count=${#need_retry_ut_arr[@]} - read retry_unittests <<< $(echo "$failed_test_lists" | grep -oEi "\-.+\(.+\)" | sed 's/(.\+)//' | sed 's/- //' ) + retry_unittests=$(echo "$failed_test_lists" | grep -oEi "\-.+\(.+\)" | sed 's/(.\+)//' | sed 's/- //' ) while ( [ $exec_times -lt $retry_time ] ) do if [[ "${exec_times}" == "0" ]] ;then @@ -1810,7 +1813,7 @@ set +x is_retry_execuate=1 fi elif [[ "${exec_times}" == "1" ]] ;then - read need_retry_ut_str <<< $(echo "$failed_test_lists" | grep -oEi "\-.+\(.+\)" | sed 's/(.\+)//' | sed 's/- //' ) + need_retry_ut_str=$(echo "$failed_test_lists" | grep -oEi "\-.+\(.+\)" | sed 's/(.\+)//' | sed 's/- //' ) need_retry_ut_arr=(${need_retry_ut_str}) need_retry_ut_count=${#need_retry_ut_arr[@]} if [ $need_retry_ut_count -lt $exec_retry_threshold ];then @@ -1828,7 +1831,7 @@ set +x if [[ "${failed_test_lists}" == "" ]];then break else - read retry_unittests <<< $(echo "$failed_test_lists" | grep -oEi "\-.+\(.+\)" | sed 's/(.\+)//' | sed 's/- //' ) + retry_unittests=$(echo "$failed_test_lists" | grep -oEi "\-.+\(.+\)" | sed 's/(.\+)//' | sed 's/- //' ) fi fi echo "=========================================" @@ -1838,7 +1841,7 @@ set +x echo "${retry_unittests}" for line in ${retry_unittests[@]} ; do - read tmp_one_tmp <<< "$( echo $single_card_tests | grep -oEi $line )" + tmp_one_tmp="$( echo $single_card_tests | grep -oEi $line )" if [[ "$tmp_one_tmp" != "" ]]; then if [[ "$one_card_retry" == "" ]]; then diff --git a/python/paddle/fluid/tests/unittests/npu/CMakeLists.txt b/python/paddle/fluid/tests/unittests/npu/CMakeLists.txt index c8fe050a5d..3764f4baea 100644 --- a/python/paddle/fluid/tests/unittests/npu/CMakeLists.txt +++ b/python/paddle/fluid/tests/unittests/npu/CMakeLists.txt @@ -13,4 +13,9 @@ if (WITH_ASCEND_CL) set_tests_properties(test_amp_check_finite_and_scale_op_npu PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE") set_tests_properties(test_flags_check_nan_inf_npu PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE") set_tests_properties(test_float_status_op_npu PROPERTIES LABELS "RUN_TYPE=EXCLUSIVE") + + # Note: the following test cases has running time more than 120s + set_tests_properties(test_nearest_interp_op_npu PROPERTIES TIMEOUT 200) + set_tests_properties(test_nearest_interp_v2_op_npu PROPERTIES TIMEOUT 200) + set_tests_properties(test_stack_op_npu PROPERTIES TIMEOUT 300) endif() -- GitLab