diff --git a/paddle/fluid/inference/tests/infer_ut/CMakeLists.txt b/paddle/fluid/inference/tests/infer_ut/CMakeLists.txt index 16d1f211a860f94dda0c507feb40678dff5446e8..50d56b3e59ae7f70ac889d1d9cee0ba3cbe801da 100644 --- a/paddle/fluid/inference/tests/infer_ut/CMakeLists.txt +++ b/paddle/fluid/inference/tests/infer_ut/CMakeLists.txt @@ -193,7 +193,11 @@ if(WITH_GTEST) include(GNUInstallDirs) include_directories(${GTEST_INSTALL_DIR}/include) add_dependencies(${DEMO_NAME} thirdparty_gtest) - target_link_libraries(${DEMO_NAME} ${GTEST_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libgtest${CMAKE_STATIC_LIBRARY_SUFFIX}) + IF(WIN32) + target_link_libraries(${DEMO_NAME} ${GTEST_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/gtest${CMAKE_STATIC_LIBRARY_SUFFIX}) + ELSE() + target_link_libraries(${DEMO_NAME} ${GTEST_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/libgtest${CMAKE_STATIC_LIBRARY_SUFFIX}) + ENDIF(WIN32) endif() if(WIN32) if(USE_TENSORRT) diff --git a/paddle/fluid/inference/tests/infer_ut/run.sh b/paddle/fluid/inference/tests/infer_ut/run.sh index 627cd56f4830c9142c8d0b36ac9577e7d8514391..d887f493b2e31355c16385e63cff9fed1d7e3a7f 100755 --- a/paddle/fluid/inference/tests/infer_ut/run.sh +++ b/paddle/fluid/inference/tests/infer_ut/run.sh @@ -23,6 +23,7 @@ TENSORRT_ROOT_DIR=$5 # TensorRT ROOT dir, default to /usr/local/TensorRT MSVC_STATIC_CRT=$6 inference_install_dir=${PADDLE_ROOT}/build/paddle_inference_install_dir EXIT_CODE=0 # init default exit code +WIN_DETECT=$(echo `uname` | grep "Win") # detect current platform export RED='\033[0;31m' # red color export NC='\033[0m' # no color @@ -48,7 +49,7 @@ if [ -d "$TENSORRT_ROOT_DIR" ]; then USE_TENSORRT=ON fi -# download vis_demo data + function download() { url_prefix=$1 model_name=$2 @@ -57,8 +58,13 @@ function download() { if [[ -e "${model_name}.tgz" ]]; then echo "${model_name}.tgz has been downloaded." else - wget -q --no-proxy ${url_prefix}/${model_name}.tgz - tar xzf *.tgz + if [ $WIN_DETECT != "" ]; then + wget -q -Y off ${url_prefix}/${model_name}.tgz + tar xzf *.tgz + else + wget -q --no-proxy ${url_prefix}/${model_name}.tgz + tar xzf *.tgz + fi fi cd .. } @@ -105,15 +111,30 @@ function compile_test() { mkdir -p ${build_dir} cd ${build_dir} TEST_NAME=$1 - cmake .. -DPADDLE_LIB=${inference_install_dir} \ + if [ $WIN_DETECT != "" ]; then + cmake .. -G "Visual Studio 15 2017" -A x64 -T host=x64 -DPADDLE_LIB=${inference_install_dir} \ -DWITH_MKL=$TURN_ON_MKL \ -DDEMO_NAME=${TEST_NAME} \ -DWITH_GPU=$TEST_GPU_CPU \ -DWITH_STATIC_LIB=OFF \ -DUSE_TENSORRT=$USE_TENSORRT \ -DTENSORRT_ROOT=$TENSORRT_ROOT_DIR \ - -DWITH_GTEST=ON - make -j$(nproc) + -DMSVC_STATIC_CRT=$MSVC_STATIC_CRT \ + -DWITH_GTEST=ON \ + -DCMAKE_CXX_FLAGS='/std:c++17' \ + -DCMAKE_BUILD_TYPE=Release + msbuild /maxcpucount /property:Configuration=Release ALL_BUILD.vcxproj + else + cmake .. -DPADDLE_LIB=${inference_install_dir} \ + -DWITH_MKL=$TURN_ON_MKL \ + -DDEMO_NAME=${TEST_NAME} \ + -DWITH_GPU=$TEST_GPU_CPU \ + -DWITH_STATIC_LIB=OFF \ + -DUSE_TENSORRT=$USE_TENSORRT \ + -DTENSORRT_ROOT=$TENSORRT_ROOT_DIR \ + -DWITH_GTEST=ON + make -j$(nproc) + fi; cd - } @@ -129,96 +150,99 @@ rm -rf * if [ $USE_TENSORRT == ON -a $TEST_GPU_CPU == ON ]; then rm -rf * + if [ $WIN_DETECT != "" ]; then + exe_dir=${build_dir}/Release + else + exe_dir=${build_dir} + fi; + printf "${YELLOW} start test_resnet50 ${NC} \n"; compile_test "test_resnet50" - ./test_resnet50 \ + ${exe_dir}/test_resnet50 \ --modeldir=$DATA_DIR/resnet50/resnet50 \ - --gtest_output=xml:test_resnet50.xml + --gtest_output=xml:${log_dir}/test_resnet50.xml if [ $? -ne 0 ]; then - echo "test_resnet50 runs failed" >> ${current_dir}/build/test_summary.txt + echo "test_resnet50 runs failed" >> ${exe_dir}/test_summary.txt EXIT_CODE=1 fi printf "${YELLOW} start test_det_mv3_db ${NC} \n"; compile_test "test_det_mv3_db" - make -j$(nproc) - ./test_det_mv3_db \ + ${exe_dir}/test_det_mv3_db \ --modeldir=$DATA_DIR/ocr_det_mv3_db/ocr_det_mv3_db \ - --gtest_output=xml:test_det_mv3_db.xml + --gtest_output=xml:${log_dir}/test_det_mv3_db.xml if [ $? -ne 0 ]; then - echo "test_det_mv3_db runs failed" >> ${current_dir}/build/test_summary.txt + echo "test_det_mv3_db runs failed" >> ${exe_dir}/test_summary.txt EXIT_CODE=1 fi printf "${YELLOW} start test_LeViT ${NC} \n"; compile_test "test_LeViT" - ./test_LeViT \ + ${exe_dir}/test_LeViT \ --modeldir=$DATA_DIR/LeViT/LeViT \ - --gtest_output=xml:test_LeViT.xml + --gtest_output=xml:${log_dir}/test_LeViT.xml if [ $? -ne 0 ]; then - echo "test_LeViT runs failed" >> ${current_dir}/build/test_summary.txt + echo "test_LeViT runs failed" >> ${exe_dir}/test_summary.txt EXIT_CODE=1 fi printf "${YELLOW} start test_ernie_text_cls ${NC} \n"; compile_test "test_ernie_text_cls" - ./test_ernie_text_cls \ + ${exe_dir}/test_ernie_text_cls \ --modeldir=$DATA_DIR/ernie_text_cls/ernie_text_cls \ - --gtest_output=xml:test_ernie_text_cls.xml + --gtest_output=xml:${log_dir}/test_ernie_text_cls.xml if [ $? -ne 0 ]; then - echo "test_ernie_text_cls runs failed" >> ${current_dir}/build/test_summary.txt + echo "test_ernie_text_cls runs failed" >> ${exe_dir}/test_summary.txt EXIT_CODE=1 fi printf "${YELLOW} start test_yolov3 ${NC} \n"; compile_test "test_yolov3" - ./test_yolov3 \ + ${exe_dir}/test_yolov3 \ --modeldir=$DATA_DIR/yolov3/yolov3 \ - --gtest_output=xml:test_yolov3.xml + --gtest_output=xml:${log_dir}/test_yolov3.xml if [ $? -ne 0 ]; then - echo "test_yolov3 runs failed" >> ${current_dir}/build/test_summary.txt + echo "test_yolov3 runs failed" >> ${exe_dir}/test_summary.txt EXIT_CODE=1 fi printf "${YELLOW} start test_ppyolo_mbv3 ${NC} \n"; compile_test "test_ppyolo_mbv3" - ./test_ppyolo_mbv3 \ + ${exe_dir}/test_ppyolo_mbv3 \ --modeldir=$DATA_DIR/ppyolo_mbv3/ppyolo_mbv3 \ - --gtest_output=xml:test_ppyolo_mbv3.xml + --gtest_output=xml:${log_dir}/test_ppyolo_mbv3.xml if [ $? -ne 0 ]; then - echo "test_ppyolo_mbv3 runs failed" >> ${current_dir}/build/test_summary.txt + echo "test_ppyolo_mbv3 runs failed" >> ${exe_dir}/test_summary.txt EXIT_CODE=1 fi printf "${YELLOW} start test_ppyolov2_r50vd ${NC} \n"; compile_test "test_ppyolov2_r50vd" - ./test_ppyolov2_r50vd \ + ${exe_dir}/test_ppyolov2_r50vd \ --modeldir=$DATA_DIR/ppyolov2_r50vd/ppyolov2_r50vd \ - --gtest_output=xml:test_ppyolov2_r50vd.xml + --gtest_output=xml:${log_dir}/test_ppyolov2_r50vd.xml if [ $? -ne 0 ]; then - echo "test_ppyolov2_r50vd runs failed" >> ${current_dir}/build/test_summary.txt + echo "test_ppyolov2_r50vd runs failed" >> ${exe_dir}/test_summary.txt EXIT_CODE=1 fi printf "${YELLOW} start test_resnet50_quant ${NC} \n"; compile_test "test_resnet50_quant" - ./test_resnet50_quant \ + ${exe_dir}/test_resnet50_quant \ --int8dir=$DATA_DIR/resnet50_quant/resnet50_quant/resnet50_quant \ --modeldir=$DATA_DIR/resnet50/resnet50 \ --datadir=$DATA_DIR/resnet50_quant/resnet50_quant/imagenet-eval-binary/9.data \ - --gtest_output=xml:test_resnet50_quant.xml + --gtest_output=xml:${log_dir}/test_resnet50_quant.xml if [ $? -ne 0 ]; then - echo "test_resnet50_quant runs failed" >> ${current_dir}/build/test_summary.txt + echo "test_resnet50_quant runs failed" >> ${exe_dir}/test_summary.txt EXIT_CODE=1 fi - - cp ./*.xml ${log_dir}; fi -if [[ -f ${current_dir}/build/test_summary.txt ]];then +if [[ -f ${exe_dir}/test_summary.txt ]];then echo "=====================test summary======================" - cat ${current_dir}/build/test_summary.txt + cat ${exe_dir}/test_summary.txt echo "========================================================" fi echo "infer_ut script finished" diff --git a/paddle/scripts/paddle_build.bat b/paddle/scripts/paddle_build.bat index a5b5a3705e514b1023607eee89756fa2dc601221..75871fe6d36eaadcd93eea6699fd3b77a21728fb 100644 --- a/paddle/scripts/paddle_build.bat +++ b/paddle/scripts/paddle_build.bat @@ -271,6 +271,7 @@ if %errorlevel% NEQ 0 exit /b 1 call :cmake || goto cmake_error call :build || goto build_error call :test_inference || goto test_inference_error +call :test_inference_ut || goto test_inference_ut_error call :zip_cc_file || goto zip_cc_file_error call :zip_c_file || goto zip_c_file_error goto:success @@ -738,6 +739,23 @@ goto:eof :check_change_of_unittest_error exit /b 1 +rem --------------------------------------------------------------------------------------------- +:test_inference_ut +@ECHO OFF +echo ======================================== +echo Step 7. Testing fluid library with infer_ut for inference ... +echo ======================================== + +cd %work_dir%\paddle\fluid\inference\tests\infer_ut +%cache_dir%\tools\busybox64.exe bash run.sh %work_dir:\=/% %WITH_MKL% %WITH_GPU% %cache_dir:\=/%/inference_demo %TENSORRT_ROOT% %MSVC_STATIC_CRT% +goto:eof + +:test_inference_ut_error +::echo 1 > %cache_dir%\error_code.txt +::type %cache_dir%\error_code.txt +echo Testing fluid library with infer_ut for inference failed! +exit /b 1 + rem --------------------------------------------------------------------------------------------- :zip_cc_file cd /d %work_dir%\%BUILD_DIR%