From 3dbabc4db48095df8806587566d5925b53546ac0 Mon Sep 17 00:00:00 2001 From: Sing_chan <51314274+betterpig@users.noreply.github.com> Date: Tue, 23 Nov 2021 12:40:37 +0800 Subject: [PATCH] modify for wincheck-inference case (#37292) * for pure fp16 * opt topk * modify for wincheck-inference case * modify according to zhouwei's comment * modify according to zhouwei's comment 2nd time Co-authored-by: zhangkaihuo --- paddle/scripts/paddle_build.bat | 5 ++++- paddle/scripts/paddle_build.sh | 4 ++-- tools/parallel_UT_rule.py | 7 ++++++- tools/windows/get_prec_ut_list.py | 16 ++++++++++++---- tools/windows/run_unittests.sh | 21 ++++++++++----------- 5 files changed, 34 insertions(+), 19 deletions(-) diff --git a/paddle/scripts/paddle_build.bat b/paddle/scripts/paddle_build.bat index ef92d96dcbb..281adabf9e2 100644 --- a/paddle/scripts/paddle_build.bat +++ b/paddle/scripts/paddle_build.bat @@ -256,11 +256,14 @@ set WITH_GPU=ON set WITH_AVX=ON set MSVC_STATIC_CRT=ON set ON_INFER=ON +set WITH_TESTING=ON +set WITH_TENSORRT=ON +set WITH_INFERENCE_API_TEST=ON call :cmake || goto cmake_error call :build || goto build_error call :test_whl_pacakage || goto test_whl_pacakage_error -:: call :test_unit || goto test_unit_error +call :test_unit || goto test_unit_error ::call :test_inference || goto test_inference_error :: call :check_change_of_unittest || goto check_change_of_unittest_error goto:success diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index bcc4cf8713c..e5a36ced0d3 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -1227,8 +1227,8 @@ set +x is_nightly='' # indicate whether the case will only run at night get_quickly_disable_ut||disable_ut_quickly='' # indicate whether the case was in quickly disable list - UT_list=$(ctest -N | awk -F ': ' '{print $2}' | sed '/^$/d' | sed '$d') - output=$(python ${PADDLE_ROOT}/tools/parallel_UT_rule.py "${UT_list}") + ctest -N | awk -F ': ' '{print $2}' | sed '/^$/d' | sed '$d' > all_ut_list + output=$(python ${PADDLE_ROOT}/tools/parallel_UT_rule.py) high_parallel_job=$(echo $output | cut -d ";" -f 1) secondary_high_parallel_job=$(echo $output | cut -d ";" -f 2) third_high_parallel_job=$(echo $output | cut -d ";" -f 3) diff --git a/tools/parallel_UT_rule.py b/tools/parallel_UT_rule.py index 647c36c8954..be9be5a8954 100644 --- a/tools/parallel_UT_rule.py +++ b/tools/parallel_UT_rule.py @@ -2205,7 +2205,12 @@ def main(): lowest_high_parallel_job = '^job$' non_parallel_job = '^job$' - test_cases = sys.argv[1] + # sys.argv[1] may exceed max_arg_length when busybox run parallel_UT_rule in windows + BUILD_DIR = os.getcwd() + file_path = os.path.join(BUILD_DIR, 'all_ut_list') + with open(file_path, 'r') as f: + test_cases = f.read() + test_cases = test_cases.split("\n") if platform.system() == 'Windows': diff --git a/tools/windows/get_prec_ut_list.py b/tools/windows/get_prec_ut_list.py index 2b89b978e45..9285fb8e84c 100644 --- a/tools/windows/get_prec_ut_list.py +++ b/tools/windows/get_prec_ut_list.py @@ -14,6 +14,8 @@ """To get a list of prec ut """ import sys +import os +import platform def get_prec_ut_list(all_test_cases, prec_test_cases): @@ -24,7 +26,7 @@ def get_prec_ut_list(all_test_cases, prec_test_cases): prec_test_cases_list_new = [item.rstrip() for item in prec_test_cases_list] if len(prec_test_cases) == 0: - return "\n".join(all_test_cases_list) + return case_to_run = ['test_prec_ut'] for case in all_test_cases_list_new: @@ -32,14 +34,20 @@ def get_prec_ut_list(all_test_cases, prec_test_cases): case_to_run.append(case) else: print("{} will not run in PRECISION_TEST mode.".format(case)) - for case in case_to_run: - print(case) + + with open(file_path, 'w') as f: + f.write('\n'.join(case_to_run)) if __name__ == '__main__': # get prec cases lists with open('ut_list', 'r') as f: prec_test_cases = f.read() - all_test_cases = sys.argv[1] + + # sys.argv[1] may exceed max_arg_length when busybox run parallel_UT_rule in windows + BUILD_DIR = os.getcwd() + file_path = os.path.join(BUILD_DIR, 'all_ut_list') + with open(file_path, 'r') as f: + all_test_cases = f.read() #prec_test_cases = sys.argv[2] get_prec_ut_list(all_test_cases, prec_test_cases) diff --git a/tools/windows/run_unittests.sh b/tools/windows/run_unittests.sh index dcf73189a77..eaeddee278f 100644 --- a/tools/windows/run_unittests.sh +++ b/tools/windows/run_unittests.sh @@ -157,7 +157,7 @@ long_time_test="^test_gru_op$|\ if [ ${WITH_GPU:-OFF} == "ON" ];then export CUDA_VISIBLE_DEVICES=0 - UT_list=$(ctest -N | awk -F ': ' '{print $2}' | sed '/^$/d' | sed '$d') + ctest -N | awk -F ': ' '{print $2}' | sed '/^$/d' | sed '$d' > all_ut_list num=$(ctest -N | awk -F ': ' '{print $2}' | sed '/^$/d' | sed '$d' | wc -l) echo "Windows 1 card TestCases count is $num" if [ ${PRECISION_TEST:-OFF} == "ON" ]; then @@ -165,19 +165,14 @@ if [ ${WITH_GPU:-OFF} == "ON" ];then if [[ -f "ut_list" ]]; then echo "PREC length: "`wc -l ut_list` precision_cases=`cat ut_list` + if [[ "$precision_cases" != "" ]];then + python ${PADDLE_ROOT}/tools/windows/get_prec_ut_list.py + fi fi fi - set +e - if [ ${PRECISION_TEST:-OFF} == "ON" ] && [[ "$precision_cases" != "" ]];then - UT_list_res=$(python ${PADDLE_ROOT}/tools/windows/get_prec_ut_list.py "$UT_list" ) - UT_list_prec=$(echo "${UT_list_res}" | grep -v 'PRECISION_TEST') - echo "${UT_list_res}" | grep 'PRECISION_TEST' - UT_list=$UT_list_prec - fi - set -e - - output=$(python ${PADDLE_ROOT}/tools/parallel_UT_rule.py "${UT_list}") + # sys.argv[1] may exceed max_arg_length when busybox run parallel_UT_rule in windows + output=$(python ${PADDLE_ROOT}/tools/parallel_UT_rule.py) cpu_parallel_job=$(echo $output | cut -d ";" -f 1) tetrad_parallel_job=$(echo $output | cut -d ";" -f 2) two_parallel_job=$(echo $output | cut -d ";" -f 3) @@ -319,6 +314,10 @@ if [ "${WITH_GPU:-OFF}" == "ON" ];then echo "========================================" exit 8; fi + if nvcc --version | grep 11.2; then + echo "Only test added_ut temporarily when running in CI-Windows-inference of CUDA 11.2." + exit 0; + fi fi run_unittest_gpu $cpu_parallel_job 10 run_unittest_gpu $tetrad_parallel_job 4 -- GitLab