Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion paddle/fluid/inference/tests/infer_ut/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
94 changes: 59 additions & 35 deletions paddle/fluid/inference/tests/infer_ut/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linux用代理能下载过吗

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

linux用代理可以下载

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段逻辑是windows用代理,Linux不用代理

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

目前修改为
Linux下:wget -q --no-proxy 取消代理
Windows下:使用busybox,wget -q -Y off 取消代理

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 ..
}
Expand Down Expand Up @@ -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 -
}

Expand All @@ -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"
Expand Down
18 changes: 18 additions & 0 deletions paddle/scripts/paddle_build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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%
Expand Down