From 49d285b94c9fcc7bdd9caafc6604344ed7fd66d8 Mon Sep 17 00:00:00 2001 From: Chunwei Date: Tue, 25 Jun 2019 10:24:46 +0000 Subject: [PATCH] enhance api test --- paddle/fluid/lite/api/CMakeLists.txt | 5 ++++- paddle/fluid/lite/api/paddle_api_test.cc | 5 ++++- paddle/fluid/lite/tools/build.sh | 27 ++++++++++++++++++------ 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/paddle/fluid/lite/api/CMakeLists.txt b/paddle/fluid/lite/api/CMakeLists.txt index 044bb902df1..ea74ed317e4 100644 --- a/paddle/fluid/lite/api/CMakeLists.txt +++ b/paddle/fluid/lite/api/CMakeLists.txt @@ -108,9 +108,12 @@ lite_cc_library(paddle_api_light SRCS paddle_api.cc DEPS light_api_impl_lite) lite_cc_test(test_paddle_api_lite SRCS paddle_api_test.cc DEPS cxx_api_lite light_api_lite paddle_api_full + ${ops_lite} + ARM_DEPS ${arm_kernels} + X86_DEPS ${x86_kernels} ARGS --model_dir=${LITE_MODEL_DIR}/lite_naive_model SERIAL) if (WITH_TESTING) - add_dependencies(test_paddle_api_lite test_apis_lite) + add_dependencies(test_paddle_api_lite extern_lite_download_lite_naive_model_tar_gz) endif() #lite_cc_binary(cxx_api_lite_bin SRCS cxx_api_bin.cc diff --git a/paddle/fluid/lite/api/paddle_api_test.cc b/paddle/fluid/lite/api/paddle_api_test.cc index eafdb67d6e8..87e930b3e8a 100644 --- a/paddle/fluid/lite/api/paddle_api_test.cc +++ b/paddle/fluid/lite/api/paddle_api_test.cc @@ -29,7 +29,10 @@ TEST(CxxApi, run) { lite_api::CxxConfig config; config.set_model_dir(FLAGS_model_dir); config.set_preferred_place(Place{TARGET(kX86), PRECISION(kFloat)}); - config.set_valid_places({Place{TARGET(kX86), PRECISION(kFloat)}}); + config.set_valid_places({ + Place{TARGET(kX86), PRECISION(kFloat)}, + Place{TARGET(kARM), PRECISION(kFloat)}, + }); auto predictor = lite_api::CreatePaddlePredictor(config); diff --git a/paddle/fluid/lite/tools/build.sh b/paddle/fluid/lite/tools/build.sh index 7a2ad12555c..3630f9da7d4 100755 --- a/paddle/fluid/lite/tools/build.sh +++ b/paddle/fluid/lite/tools/build.sh @@ -134,14 +134,26 @@ function test_arm_android { local testpath=$(find ./paddle/fluid -name ${test_name}) - # if [[ "$test_name" == "test_light_api" ]]; then - # local model_path=$(find . -name "lite_naive_model") - # arm_push_necessary_file $port $model_path $adb_work_dir - # fi + adb -s emulator-${port} push ${testpath} ${adb_work_dir} + adb -s emulator-${port} shell "${adb_work_dir}/${test_name}" +} + +# test the inference high level api +function test_arm_api { + local port=$1 + local test_name="test_paddle_api_lite" + + make $test_name -j$NUM_CORES_FOR_COMPILE + + local model_path=$(find . -name "lite_naive_model") + local remote_model=${adb_work_dir}/paddle_api + local testpath=$(find ./paddle/fluid -name ${test_name}) + arm_push_necessary_file $port $model_path $remote_model + adb -s emulator-${port} shell mkdir -p $remote_model adb -s emulator-${port} push ${testpath} ${adb_work_dir} adb -s emulator-${port} shell chmod +x "${adb_work_dir}/${test_name}" - adb -s emulator-${port} shell "./${adb_work_dir}/${test_name}" + adb -s emulator-${port} shell "${adb_work_dir}/${test_name} --model_dir $remote_model" } function test_arm_model { @@ -253,11 +265,14 @@ function test_arm { echo "android do not need armv7hf" return 0 fi - + echo "test file: ${TESTS_FILE}" for _test in $(cat $TESTS_FILE); do test_arm_android $_test $port done + + # test finally + test_arm_api $port } function prepare_emulator { -- GitLab