From 24ced1d0b916593155516962fb673717d85fc117 Mon Sep 17 00:00:00 2001 From: Luo Tao Date: Thu, 12 Jul 2018 12:12:08 +0800 Subject: [PATCH] add independent demo for test static fluid library --- paddle/contrib/inference/demo_ci/CMakeLists.txt | 2 -- paddle/contrib/inference/demo_ci/run.sh | 14 ++++++-------- paddle/fluid/inference/CMakeLists.txt | 13 +++++++------ paddle/scripts/paddle_build.sh | 2 ++ 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/paddle/contrib/inference/demo_ci/CMakeLists.txt b/paddle/contrib/inference/demo_ci/CMakeLists.txt index 789bff7f23c..600f5992848 100644 --- a/paddle/contrib/inference/demo_ci/CMakeLists.txt +++ b/paddle/contrib/inference/demo_ci/CMakeLists.txt @@ -54,9 +54,7 @@ endif() if(WITH_STATIC_LIB) set(DEPS - "-Wl,--whole-archive" ${PADDLE_LIB}/paddle/fluid/inference/libpaddle_fluid.a - "-Wl,--no-whole-archive" ${PADDLE_LIB}/contrib/inference/libpaddle_inference_api.a) else() # Note: libpaddle_inference_api.so must put before libpaddle_fluid.so diff --git a/paddle/contrib/inference/demo_ci/run.sh b/paddle/contrib/inference/demo_ci/run.sh index e3a7269af79..a14b72dcbcd 100755 --- a/paddle/contrib/inference/demo_ci/run.sh +++ b/paddle/contrib/inference/demo_ci/run.sh @@ -11,24 +11,22 @@ fi mkdir -p build cd build -for WITH_STATIC_LIB in false; do +for WITH_STATIC_LIB in ON OFF; do rm -rf * cmake .. -DPADDLE_LIB=${PADDLE_ROOT}/build/fluid_install_dir/ \ -DWITH_MKL=$WITH_MKL \ -DDEMO_NAME=simple_on_word2vec \ -DWITH_GPU=$WITH_GPU \ -DWITH_STATIC_LIB=$WITH_STATIC_LIB - make + make -j for use_gpu in $use_gpu_list; do ./simple_on_word2vec \ --dirname=${PADDLE_ROOT}/build/python/paddle/fluid/tests/book/word2vec.inference.model \ --use_gpu=$use_gpu + if [ $? -ne 0 ]; then + echo "inference demo runs fail." + exit 1 + fi done done -if [ $? -eq 0 ]; then - exit 0 -else - echo "inference demo runs fail." - exit 1 -fi set +x diff --git a/paddle/fluid/inference/CMakeLists.txt b/paddle/fluid/inference/CMakeLists.txt index b1c33c3415f..6c80c69c100 100644 --- a/paddle/fluid/inference/CMakeLists.txt +++ b/paddle/fluid/inference/CMakeLists.txt @@ -1,3 +1,10 @@ +# analysis and tensorrt must be added before creating static library, +# otherwise, there would be undefined reference to them in static library. +add_subdirectory(analysis) +if (TENSORRT_FOUND) + add_subdirectory(tensorrt) +endif() + set(FLUID_CORE_MODULES proto_desc memory lod_tensor executor ) # TODO(panyx0718): Should this be called paddle_fluid_inference_api_internal? @@ -35,9 +42,3 @@ if(WITH_TESTING) # both tests/book and analysis depends the models that generated by python/paddle/fluid/tests/book add_subdirectory(tests/book) endif() - -add_subdirectory(analysis) - -if (TENSORRT_FOUND) - add_subdirectory(tensorrt) -endif() diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index bf45c11a9de..f81131e36dd 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -508,6 +508,7 @@ function gen_fluid_inference_lib() { Deploying fluid inference library ... ======================================== EOF + cmake .. -DWITH_DISTRIBUTE=OFF make -j `nproc` inference_lib_dist cd ${PADDLE_ROOT}/build cp -r fluid_install_dir fluid @@ -569,6 +570,7 @@ function main() { fluid_inference_lib) cmake_gen ${PYTHON_ABI:-""} gen_fluid_inference_lib + test_fluid_inference_lib ;; check_style) check_style -- GitLab