From f34d4ad4dfa46daaa2d71af851590ea7a2af4645 Mon Sep 17 00:00:00 2001 From: masimeng1994 <1057010459@qq.com> Date: Fri, 17 Mar 2023 14:29:31 +0800 Subject: [PATCH] [runtime] fix vad and cls cmake (#3050) * fix vad and cls cmake --- runtime/CMakeLists.txt | 4 +--- runtime/build.sh | 21 +++++++++++++++------ runtime/cmake/glog.cmake | 4 ++-- runtime/engine/cls/nnet/CMakeLists.txt | 4 ++-- runtime/engine/cls/nnet/panns_nnet.cc | 2 +- runtime/engine/cls/nnet/panns_nnet_main.cc | 1 + runtime/engine/vad/nnet/CMakeLists.txt | 2 +- 7 files changed, 23 insertions(+), 15 deletions(-) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index efeb6218..e48292e8 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -72,9 +72,7 @@ if(WITH_TESTING) endif() # fastdeploy -if(NOT WITH_ASR) - include(fastdeploy) -endif() +include(fastdeploy) if(WITH_ASR) # openfst diff --git a/runtime/build.sh b/runtime/build.sh index 4a27766a..0ee628fd 100755 --- a/runtime/build.sh +++ b/runtime/build.sh @@ -6,15 +6,24 @@ BUILD_DIR=${BUILD_ROOT}/x86_64 mkdir -p ${BUILD_DIR} +BUILD_TYPE=Release +#BUILD_TYPE=Debug +BUILD_SO=OFF +BUILD_ASR=OFF +BUILD_CLS=ON +BUILD_VAD=ON +FASTDEPLOY_INSTALL_DIR="" + # the build script had verified in the paddlepaddle docker image. # please follow the instruction below to install PaddlePaddle image. # https://www.paddlepaddle.org.cn/documentation/docs/zh/install/docker/linux-docker.html #cmake -B build -DBUILD_SHARED_LIBS=OFF -DWITH_ASR=OFF -DWITH_CLS=OFF -DWITH_VAD=ON -DFASTDEPLOY_INSTALL_DIR=/workspace/zhanghui/paddle/FastDeploy/build/Android/arm64-v8a-api-21/install cmake -B ${BUILD_DIR} \ - -DCMAKE_BUILD_TYPE=Release \ - -DBUILD_SHARED_LIBS=OFF \ - -DWITH_ASR=OFF \ - -DWITH_CLS=OFF \ - -DWITH_VAD=ON \ - -DFASTDEPLOY_INSTALL_DIR=/workspace/zhanghui/paddle/FastDeploy/build/Linux/x86_64/install + -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ + -DBUILD_SHARED_LIBS=${BUILD_SO} \ + -DWITH_ASR=${BUILD_ASR} \ + -DWITH_CLS=${BUILD_CLS} \ + -DWITH_VAD=${BUILD_VAD} \ + -DFASTDEPLOY_INSTALL_DIR=${FASTDEPLOY_INSTALL_DIR} + cmake --build ${BUILD_DIR} -j diff --git a/runtime/cmake/glog.cmake b/runtime/cmake/glog.cmake index 51d0ef06..898562c7 100644 --- a/runtime/cmake/glog.cmake +++ b/runtime/cmake/glog.cmake @@ -28,8 +28,8 @@ endif() if(ANDROID) add_library(extern_glog INTERFACE) - add_dependencies(extern_glog gflags) + add_dependencies(glog gflags) else() # UNIX add_library(extern_glog ALIAS glog) - add_dependencies(extern_glog gflags) + add_dependencies(glog gflags) endif() \ No newline at end of file diff --git a/runtime/engine/cls/nnet/CMakeLists.txt b/runtime/engine/cls/nnet/CMakeLists.txt index d331d31a..652e05b3 100644 --- a/runtime/engine/cls/nnet/CMakeLists.txt +++ b/runtime/engine/cls/nnet/CMakeLists.txt @@ -4,8 +4,8 @@ set(srcs ) add_library(cls ${srcs}) -target_link_libraries(cls INTERFACE -static-libstdc++;-Wl,-Bsymbolic ${FASTDEPLOY_LIBS} kaldi-matrix kaldi-base frontend utils ) +target_link_libraries(cls PRIVATE ${FASTDEPLOY_LIBS} kaldi-matrix kaldi-base frontend utils ) set(bin_name panns_nnet_main) add_executable(${bin_name} ${CMAKE_CURRENT_SOURCE_DIR}/${bin_name}.cc) -target_link_libraries(${bin_name} -static-libstdc++;-Wl,-Bsymbolic gflags glog) +target_link_libraries(${bin_name} gflags glog cls) diff --git a/runtime/engine/cls/nnet/panns_nnet.cc b/runtime/engine/cls/nnet/panns_nnet.cc index bd2265d4..2edf71f2 100644 --- a/runtime/engine/cls/nnet/panns_nnet.cc +++ b/runtime/engine/cls/nnet/panns_nnet.cc @@ -67,7 +67,7 @@ int ClsNnet::Init(const ClsNnetConf& conf) { runtime_option.UsePaddleInferBackend(); #endif runtime_option.SetCpuThreadNum(conf.num_cpu_thread_); - runtime_option.DeletePaddleBackendPass("simplify_with_basic_ops_pass"); + // runtime_option.DeletePaddleBackendPass("simplify_with_basic_ops_pass"); runtime_ = std::unique_ptr(new fastdeploy::Runtime()); if (!runtime_->Init(runtime_option)) { std::cerr << "--- Init FastDeploy Runitme Failed! " diff --git a/runtime/engine/cls/nnet/panns_nnet_main.cc b/runtime/engine/cls/nnet/panns_nnet_main.cc index 14f91fc7..44072082 100644 --- a/runtime/engine/cls/nnet/panns_nnet_main.cc +++ b/runtime/engine/cls/nnet/panns_nnet_main.cc @@ -16,6 +16,7 @@ #include #include "base/flags.h" +#include "base/log.h" #include "cls/nnet/panns_interface.h" DEFINE_string(conf_path, "", "config path"); diff --git a/runtime/engine/vad/nnet/CMakeLists.txt b/runtime/engine/vad/nnet/CMakeLists.txt index 22c9f760..8fea3b19 100644 --- a/runtime/engine/vad/nnet/CMakeLists.txt +++ b/runtime/engine/vad/nnet/CMakeLists.txt @@ -13,4 +13,4 @@ target_link_libraries(${bin_name} pps_vad) file(RELATIVE_PATH DEST_DIR ${ENGINE_ROOT} ${CMAKE_CURRENT_SOURCE_DIR}) install(TARGETS pps_vad DESTINATION lib) -install(TARGETS extern_glog DESTINATION lib) \ No newline at end of file +install(TARGETS glog DESTINATION lib) \ No newline at end of file