From ac70275a647c33c9c683966a60f282a229aa15e0 Mon Sep 17 00:00:00 2001 From: Zhang Jun Date: Thu, 14 Jan 2021 13:53:18 +0800 Subject: [PATCH] [cherry-pick 2.0]enable MakeCipher api for inference (#30389) --- paddle/fluid/framework/io/crypto/cipher.cc | 4 ++-- paddle/fluid/inference/CMakeLists.txt | 22 ++++++++++++++-------- paddle/fluid/inference/api/paddle_api.h | 3 +++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/paddle/fluid/framework/io/crypto/cipher.cc b/paddle/fluid/framework/io/crypto/cipher.cc index 316f8f9c751..6a29419ffb3 100644 --- a/paddle/fluid/framework/io/crypto/cipher.cc +++ b/paddle/fluid/framework/io/crypto/cipher.cc @@ -56,9 +56,9 @@ std::shared_ptr CipherFactory::CreateCipher( } } // namespace framework -#ifdef PADDLE_ON_INFERENCE + std::shared_ptr MakeCipher(const std::string& config_file) { return framework::CipherFactory::CreateCipher(config_file); } -#endif + } // namespace paddle diff --git a/paddle/fluid/inference/CMakeLists.txt b/paddle/fluid/inference/CMakeLists.txt index 1896be4f921..fb55d546362 100644 --- a/paddle/fluid/inference/CMakeLists.txt +++ b/paddle/fluid/inference/CMakeLists.txt @@ -76,14 +76,20 @@ set(SHARED_INFERENCE_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/utils/io_utils.cc ${mkldnn_quantizer_src_file}) -# Create shared inference library defaultly -if(NOT WITH_PSCORE) - cc_library(paddle_fluid_shared SHARED SRCS ${SHARED_INFERENCE_SRCS} - DEPS ${fluid_modules} analysis_predictor) -else() - cc_library(paddle_fluid_shared SHARED SRCS ${SHARED_INFERENCE_SRCS} - DEPS ${fluid_modules} analysis_predictor fleet ps_service) -endif() +# shared inference library deps +set(SHARED_INFERENCE_DEPS ${fluid_modules} analysis_predictor) + +if (WITH_CRYPTO) + set(SHARED_INFERENCE_DEPS ${SHARED_INFERENCE_DEPS} paddle_crypto) +endif (WITH_CRYPTO) + +if (WITH_PSCORE) + set(SHARED_INFERENCE_DEPS ${SHARED_INFERENCE_DEPS} fleet ps_service) +endif () + +# Create shared inference library +cc_library(paddle_fluid_shared SHARED SRCS ${SHARED_INFERENCE_SRCS} + DEPS ${SHARED_INFERENCE_DEPS}) get_property(os_dependency_modules GLOBAL PROPERTY OS_DEPENDENCY_MODULES) target_link_libraries(paddle_fluid_shared ${os_dependency_modules}) diff --git a/paddle/fluid/inference/api/paddle_api.h b/paddle/fluid/inference/api/paddle_api.h index 76ed45be8e6..08ce6abe1d4 100644 --- a/paddle/fluid/inference/api/paddle_api.h +++ b/paddle/fluid/inference/api/paddle_api.h @@ -450,4 +450,7 @@ PD_INFER_DECL std::string get_version(); PD_INFER_DECL std::string UpdateDllFlag(const char* name, const char* value); +PD_INFER_DECL std::shared_ptr MakeCipher( + const std::string& config_file); + } // namespace paddle -- GitLab