未验证 提交 4d5ddbf1 编写于 作者: T tianshuo78520a 提交者: GitHub

add xpu test (#27622)

* add xpu test

* notest;add kunlun_test

* notest;add kunlun_test

* notest;test=kunlun

* notest;test=kunlun

* notest;test=kunlun

* notest;test=kunlun

* test=kunlun
上级 d15cbe70
...@@ -246,6 +246,7 @@ function cmake_base() { ...@@ -246,6 +246,7 @@ function cmake_base() {
-DWITH_GRPC=${grpc_flag} -DWITH_GRPC=${grpc_flag}
-DWITH_GLOO=${gloo_flag} -DWITH_GLOO=${gloo_flag}
-DWITH_LITE=${WITH_LITE:-OFF} -DWITH_LITE=${WITH_LITE:-OFF}
-DWITH_XPU=${WITH_XPU:-OFF}
-DLITE_GIT_TAG=develop -DLITE_GIT_TAG=develop
======================================== ========================================
EOF EOF
...@@ -277,6 +278,7 @@ EOF ...@@ -277,6 +278,7 @@ EOF
-DWITH_GRPC=${grpc_flag} \ -DWITH_GRPC=${grpc_flag} \
-DWITH_GLOO=${gloo_flag} \ -DWITH_GLOO=${gloo_flag} \
-DLITE_GIT_TAG=develop \ -DLITE_GIT_TAG=develop \
-DWITH_XPU=${WITH_XPU:-OFF} \
-DWITH_LITE=${WITH_LITE:-OFF};build_error=$? -DWITH_LITE=${WITH_LITE:-OFF};build_error=$?
if [ "$build_error" != 0 ];then if [ "$build_error" != 0 ];then
exit 7; exit 7;
...@@ -895,7 +897,11 @@ function card_test() { ...@@ -895,7 +897,11 @@ function card_test() {
case_count $1 $2 case_count $1 $2
ut_startTime_s=`date +%s` ut_startTime_s=`date +%s`
# get the CUDA device count # get the CUDA device count
CUDA_DEVICE_COUNT=$(nvidia-smi -L | wc -l) if [ "${WITH_XPU}" == "ON" ];then
CUDA_DEVICE_COUNT=4
else
CUDA_DEVICE_COUNT=$(nvidia-smi -L | wc -l)
fi
testcases=$1 testcases=$1
if (( $# > 1 )); then if (( $# > 1 )); then
...@@ -1163,6 +1169,41 @@ EOF ...@@ -1163,6 +1169,41 @@ EOF
fi fi
} }
function parallel_test_base_xpu() {
mkdir -p ${PADDLE_ROOT}/build
cd ${PADDLE_ROOT}/build
if [ ${WITH_TESTING:-ON} == "ON" ] ; then
cat <<EOF
========================================
Running unit cpu tests ...
========================================
EOF
set +x
ut_startTime_s=`date +%s`
test_cases=$(ctest -N -V | grep "_xpu" ) # cases list which would be run exclusively
while read -r line; do
if [[ "$line" == "" ]]; then
continue
fi
read testcase <<< $(echo "$line"|grep -oEi "\w+$")
if [[ "$single_card_tests" == "" ]]; then
single_card_tests="^$testcase$"
else
single_card_tests="$single_card_tests|^$testcase$"
fi
done <<< "$test_cases";
card_test "$single_card_tests" 1
collect_failed_tests
set -x
ut_endTime_s=`date +%s`
echo "XPU testCase Time: $[ $ut_endTime_s - $ut_startTime_s ]s"
if [[ "$EXIT_CODE" != "0" ]]; then
exit 8;
fi
fi
}
function parallel_test() { function parallel_test() {
ut_total_startTime_s=`date +%s` ut_total_startTime_s=`date +%s`
mkdir -p ${PADDLE_ROOT}/build mkdir -p ${PADDLE_ROOT}/build
...@@ -1171,7 +1212,11 @@ function parallel_test() { ...@@ -1171,7 +1212,11 @@ function parallel_test() {
if [ "$WITH_GPU" == "ON" ];then if [ "$WITH_GPU" == "ON" ];then
parallel_test_base_gpu parallel_test_base_gpu
else else
parallel_test_base_cpu ${PROC_RUN:-1} if [ "$WITH_XPU" == "ON" ];then
parallel_test_base_xpu
else
parallel_test_base_cpu ${PROC_RUN:-1}
fi
fi fi
ut_total_endTime_s=`date +%s` ut_total_endTime_s=`date +%s`
echo "TestCases Total Time: $[ $ut_total_endTime_s - $ut_total_startTime_s ]s" echo "TestCases Total Time: $[ $ut_total_endTime_s - $ut_total_startTime_s ]s"
...@@ -1500,6 +1545,7 @@ EOF ...@@ -1500,6 +1545,7 @@ EOF
fi fi
} }
function build_document_preview() { function build_document_preview() {
sh /paddle/tools/document_preview.sh ${PORT} sh /paddle/tools/document_preview.sh ${PORT}
} }
...@@ -1666,6 +1712,10 @@ function main() { ...@@ -1666,6 +1712,10 @@ function main() {
cmake_gen_and_build ${PYTHON_ABI:-""} ${parallel_number} cmake_gen_and_build ${PYTHON_ABI:-""} ${parallel_number}
parallel_test parallel_test
;; ;;
check_xpu)
cmake_gen_and_build ${PYTHON_ABI:-""} ${parallel_number}
parallel_test
;;
cmake_gen) cmake_gen)
cmake_gen ${PYTHON_ABI:-""} cmake_gen ${PYTHON_ABI:-""}
;; ;;
......
...@@ -547,6 +547,10 @@ add_subdirectory(sequence) ...@@ -547,6 +547,10 @@ add_subdirectory(sequence)
add_subdirectory(dygraph_to_static) add_subdirectory(dygraph_to_static)
add_subdirectory(rnn) add_subdirectory(rnn)
if (WITH_XPU)
add_subdirectory(xpu)
endif()
if (WITH_MKLDNN) if (WITH_MKLDNN)
add_subdirectory(mkldnn) add_subdirectory(mkldnn)
endif() endif()
......
file(GLOB TEST_OPS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "test_*.py")
string(REPLACE ".py" "" TEST_OPS "${TEST_OPS}")
foreach(TEST_OP ${TEST_OPS})
py_test_modules(${TEST_OP} MODULES ${TEST_OP})
endforeach(TEST_OP)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册