未验证 提交 6064c2f4 编写于 作者: H hong19860320 提交者: GitHub

[XPU] Enable XPU CI (#3796)

上级 79a32b9d
......@@ -53,6 +53,8 @@ if (WITH_TESTING)
lite_download_and_uncompress(${LITE_MODEL_DIR} ${LITE_URL} "resnet50.tar.gz")
lite_download_and_uncompress(${LITE_MODEL_DIR} ${LITE_URL} "inception_v4_simple.tar.gz")
lite_download_and_uncompress(${LITE_MODEL_DIR} ${LITE_URL} "step_rnn.tar.gz")
lite_download_and_uncompress(${LITE_MODEL_DIR} ${LITE_URL} "bert.tar.gz")
lite_download_and_uncompress(${LITE_MODEL_DIR} ${LITE_URL} "ernie.tar.gz")
endif()
endif()
......
......@@ -3,14 +3,17 @@ if(LITE_WITH_XPU)
DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
${ops} ${host_kernels} ${x86_kernels} ${xpu_kernels}
ARGS --model_dir=${LITE_MODEL_DIR}/resnet50)
add_dependencies(test_resnet50_lite_xpu extern_lite_download_resnet50_tar_gz)
lite_cc_test(test_ernie_lite_xpu SRCS test_ernie_lite_xpu.cc
DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
${ops} ${host_kernels} ${x86_kernels} ${xpu_kernels}
ARGS --model_dir=${LITE_MODEL_DIR}/resnet50)
ARGS --model_dir=${LITE_MODEL_DIR}/ernie)
add_dependencies(test_ernie_lite_xpu extern_lite_download_ernie_tar_gz)
lite_cc_test(test_bert_lite_xpu SRCS test_bert_lite_xpu.cc
DEPS mir_passes lite_api_test_helper paddle_api_full paddle_api_light gflags utils
${ops} ${host_kernels} ${x86_kernels} ${xpu_kernels}
ARGS --model_dir=${LITE_MODEL_DIR}/resnet50)
ARGS --model_dir=${LITE_MODEL_DIR}/bert)
add_dependencies(test_bert_lite_xpu extern_lite_download_bert_tar_gz)
endif()
if(LITE_WITH_RKNPU)
......
......@@ -93,7 +93,7 @@ TEST(Ernie, test_ernie_lite_xpu) {
for (size_t i = 0; i < results.size(); ++i) {
for (size_t j = 0; j < results[i].size(); ++j) {
EXPECT_NEAR(
out->data<float>()[j + (out->shape()[1] * i)], results[i][j], 1e-5);
out->data<float>()[j + (out->shape()[1] * i)], results[i][j], 3e-5);
}
}
}
......
......@@ -93,7 +93,7 @@ TEST(Ernie, test_ernie_lite_xpu) {
for (size_t i = 0; i < results.size(); ++i) {
for (size_t j = 0; j < results[i].size(); ++j) {
EXPECT_NEAR(
out->data<float>()[j + (out->shape()[1] * i)], results[i][j], 1e-5);
out->data<float>()[j + (out->shape()[1] * i)], results[i][j], 2e-5);
}
}
}
......
......@@ -300,7 +300,7 @@ TEST(Activation_relu, precision) {
abs_error = 1e-2; // Using fp16 in NPU
#elif defined(LITE_WITH_ARM)
place = TARGET(kARM);
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......@@ -426,7 +426,7 @@ TEST(Activation_tanh, precision) {
abs_error = 1e-2; // Using fp16 in NPU
#elif defined(LITE_WITH_ARM)
place = TARGET(kARM);
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......@@ -572,7 +572,7 @@ TEST(Activation_gelu, precision) {
LOG(INFO) << "test gelu op";
Place place;
float abs_error = 2e-5;
#if defined(LITE_WITH_XPU)
#if defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......
......@@ -157,7 +157,7 @@ TEST(BatchNorm, precision) {
LOG(INFO) << "test BatchNorm op";
float abs_error = 2e-5;
Place place;
#if defined(LITE_WITH_XPU)
#if defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#elif defined(LITE_WITH_NPU)
place = TARGET(kNPU);
......
......@@ -135,7 +135,7 @@ TEST(Cast, precision) {
float abs_error = 2e-5;
#if defined(LITE_WITH_ARM)
place = TARGET(kARM);
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......
......@@ -94,7 +94,7 @@ TEST(Dropout, precision) {
#if defined(LITE_WITH_NPU)
place = TARGET(kNPU);
abs_error = 1e-2; // Using fp16 in NPU
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......
......@@ -228,7 +228,7 @@ TEST(Elementwise, precision) {
abs_error = 1e-2; // use fp16 in npu
#elif defined(LITE_WITH_ARM)
place = TARGET(kARM);
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......
......@@ -98,7 +98,7 @@ TEST(Gather, precision) {
abs_error = 1e-2; // use fp16 in npu
#elif defined(LITE_WITH_ARM)
place = TARGET(kARM);
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......
......@@ -147,7 +147,7 @@ TEST(LayerNorm, precision) {
LOG(INFO) << "test layer_norm op";
float abs_error = 2e-5;
Place place;
#if defined(LITE_WITH_XPU)
#if defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#elif defined(LITE_WITH_NPU)
place = TARGET(kNPU);
......
......@@ -116,7 +116,7 @@ TEST(LookupTable, precision) {
abs_error = 1e-2;
#elif defined(LITE_WITH_ARM)
place = TARGET(kARM);
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......@@ -132,7 +132,8 @@ TEST(LookupTable, precision) {
std::vector<std::vector<int64_t>>{{5, 2, 3, 1}, {2, 3, 1}, {3, 1}}) {
for (auto w_dims :
std::vector<std::vector<int64_t>>{{4, 2}, {6, 8}, {12, 15}}) {
#if defined(LITE_WITH_XPU) && defined(LITE_WITH_NPU)
#if (defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)) || \
defined(LITE_WITH_NPU)
for (auto padding_idx :
std::vector<int64_t>{-1}) { // Only -1 is supported by XPU or NPU
#else
......
......@@ -457,7 +457,7 @@ TEST(Matmul2x2, precision) {
abs_error = 1e-2; // use fp16 in npu
#elif defined(LITE_WITH_ARM)
place = TARGET(kARM);
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......@@ -489,7 +489,7 @@ TEST(Matmul2x2_y_transpose, precision) {
abs_error = 1e-2; // use fp16 in npu
#elif defined(LITE_WITH_ARM)
place = TARGET(kARM);
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......
......@@ -127,7 +127,7 @@ TEST(Mul, precision) {
#if defined(LITE_WITH_NPU)
place = TARGET(kNPU);
abs_error = 1e-2; // use fp16 in npu
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......
......@@ -478,7 +478,7 @@ TEST(multiclass_nms, precision) {
Place place;
#if defined(LITE_WITH_ARM)
place = TARGET(kHost);
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......
......@@ -381,7 +381,7 @@ TEST(Pool, precision) {
#if defined(LITE_WITH_NPU)
place = TARGET(kNPU);
abs_error = 1e-2; // Using fp16 in NPU
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......
......@@ -206,7 +206,7 @@ TEST(Reshape, precision) {
abs_error = 1e-2; // Using fp16 in NPU
#elif defined(LITE_WITH_ARM)
place = TARGET(kHost);
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......
......@@ -165,7 +165,7 @@ TEST(Scale, precision) {
abs_error = 4e-3; // Using fp16 in NPU
#elif defined(LITE_WITH_ARM)
place = TARGET(kARM);
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
abs_error = 3e-4; // Some operations use fp16 in XPU
#elif defined(LITE_WITH_X86)
......
......@@ -273,7 +273,7 @@ TEST(Slice, precision) {
test_slice(place);
test_slice_tensor(place);
test_slice_tensor_list(place);
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
Place place(TARGET(kXPU));
test_slice(place);
#endif
......
......@@ -103,7 +103,7 @@ TEST(Softmax, precision) {
#if defined(LITE_WITH_NPU)
place = TARGET(kNPU);
abs_error = 4e-3; // Using fp16 in NPU
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......
......@@ -106,7 +106,7 @@ TEST(Stack, precision) {
Place place;
#ifdef LITE_WITH_ARM
place = TARGET(kARM);
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......
......@@ -164,7 +164,7 @@ TEST(Transpose, precision) {
LOG(INFO) << "test Transpose op";
float abs_error = 2e-5;
Place place;
#ifdef LITE_WITH_XPU
#if defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#elif defined(LITE_WITH_NPU)
place = TARGET(kNPU);
......
......@@ -247,7 +247,7 @@ TEST(YoloBox, precision) {
Place place;
#if defined(LITE_WITH_ARM)
place = TARGET(kARM);
#elif defined(LITE_WITH_XPU)
#elif defined(LITE_WITH_XPU) && defined(LITE_WITH_XTCL)
place = TARGET(kXPU);
#else
return;
......
......@@ -353,7 +353,7 @@ function cmake_xpu {
-DWITH_MKL=ON \
-DLITE_BUILD_EXTRA=ON \
-DLITE_WITH_XPU=ON \
-DXPU_SDK_ROOT="$(pwd)/../../XPU_SDK"
-DXPU_SDK_ROOT="/opt/output"
}
function build_xpu {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册