diff --git a/cmake/external/xpu.cmake b/cmake/external/xpu.cmake index 137d894f647ca2b0167a85bda5a2613153b5d6b8..344518c9600fcee3a7ccdfa9e1b6be5aff905bc0 100644 --- a/cmake/external/xpu.cmake +++ b/cmake/external/xpu.cmake @@ -4,6 +4,8 @@ endif() INCLUDE(ExternalProject) SET(XPU_PROJECT "extern_xpu") +SET(XPU_API_LIB_NAME "libxpuapi.so") +SET(XPU_RT_LIB_NAME "libxpurt.so") if(NOT XPU_SDK_ROOT) if (WITH_AARCH64) @@ -20,8 +22,6 @@ if(NOT XPU_SDK_ROOT) SET(XPU_API_INC_DIR "${THIRD_PARTY_PATH}/install/xpu/include") SET(XPU_LIB_DIR "${THIRD_PARTY_PATH}/install/xpu/lib") - SET(XPU_API_LIB_NAME "libxpuapi.so") - SET(XPU_RT_LIB_NAME "libxpurt.so") SET(XPU_API_LIB "${XPU_LIB_DIR}/${XPU_API_LIB_NAME}") SET(XPU_RT_LIB "${XPU_LIB_DIR}/${XPU_RT_LIB_NAME}") diff --git a/cmake/third_party.cmake b/cmake/third_party.cmake index 65600ba7fb76ded2eced1735677db8d6c21752f6..02e04c85af0029f587fbd158ef16a0f9039b175c 100644 --- a/cmake/third_party.cmake +++ b/cmake/third_party.cmake @@ -322,6 +322,7 @@ endif (WITH_LITE) if (WITH_CRYPTO) include(external/cryptopp) # download, build, install cryptopp + add_definitions(-DPADDLE_WITH_CRYPTO) endif (WITH_CRYPTO) add_custom_target(third_party ALL DEPENDS ${third_party_deps}) diff --git a/paddle/fluid/framework/io/crypto/cipher.cc b/paddle/fluid/framework/io/crypto/cipher.cc index 6a29419ffb3b8345c600f8541ca5155ba9f7bc8e..536e0b722a4b9fe97f1aed51807c9771dd2bf4a4 100644 --- a/paddle/fluid/framework/io/crypto/cipher.cc +++ b/paddle/fluid/framework/io/crypto/cipher.cc @@ -56,9 +56,4 @@ std::shared_ptr CipherFactory::CreateCipher( } } // namespace framework - -std::shared_ptr MakeCipher(const std::string& config_file) { - return framework::CipherFactory::CreateCipher(config_file); -} - } // namespace paddle diff --git a/paddle/fluid/inference/api/CMakeLists.txt b/paddle/fluid/inference/api/CMakeLists.txt index 22aa210c97ef821f6d18b704c71d8b23eeb74944..1da28d71f0e209f1b4f300ef7fb9726e547de7e6 100755 --- a/paddle/fluid/inference/api/CMakeLists.txt +++ b/paddle/fluid/inference/api/CMakeLists.txt @@ -30,8 +30,14 @@ endif() cc_library(analysis_config SRCS analysis_config.cc DEPS ${mkldnn_quantizer_cfg} lod_tensor paddle_pass_builder) cc_library(paddle_pass_builder SRCS paddle_pass_builder.cc) -cc_library(paddle_inference_api SRCS api.cc api_impl.cc helper.cc DEPS lod_tensor scope reset_tensor_array - analysis_config zero_copy_tensor trainer_desc_proto) +if(WITH_CRYPTO) + cc_library(paddle_inference_api SRCS api.cc api_impl.cc helper.cc DEPS lod_tensor scope reset_tensor_array + analysis_config zero_copy_tensor trainer_desc_proto paddle_crypto) + else() + cc_library(paddle_inference_api SRCS api.cc api_impl.cc helper.cc DEPS lod_tensor scope reset_tensor_array + analysis_config zero_copy_tensor trainer_desc_proto) + endif() + if(WIN32) target_link_libraries(paddle_inference_api gflags) diff --git a/paddle/fluid/inference/api/api.cc b/paddle/fluid/inference/api/api.cc index 840541246aff4d6f5dec1d8b3f8e5892bdcb6e9d..a698ca2dd7802925e6c01fd07b42e2efbdcda1bf 100644 --- a/paddle/fluid/inference/api/api.cc +++ b/paddle/fluid/inference/api/api.cc @@ -146,4 +146,10 @@ std::string UpdateDllFlag(const char *name, const char *value) { return ret; } +#ifdef PADDLE_WITH_CRYPTO +std::shared_ptr MakeCipher(const std::string &config_file) { + return framework::CipherFactory::CreateCipher(config_file); +} +#endif + } // namespace paddle diff --git a/paddle/fluid/inference/api/api_tester.cc b/paddle/fluid/inference/api/api_tester.cc index e8d0a1659d3072b4dae0e0152f258d9052b2b506..108bf0ec04b53004f2e394d9d1f251417892d214 100644 --- a/paddle/fluid/inference/api/api_tester.cc +++ b/paddle/fluid/inference/api/api_tester.cc @@ -91,4 +91,9 @@ TEST(paddle_inference_api, AnalysisConfigCopyCtor) { CHECK_NE(ps, delete_pass); } } + +#ifdef PADDLE_WITH_CRYPTO +TEST(paddle_inference_api, crypto) { paddle::MakeCipher(""); } +#endif + } // namespace paddle diff --git a/paddle/fluid/inference/api/demo_ci/CMakeLists.txt b/paddle/fluid/inference/api/demo_ci/CMakeLists.txt index e24d83af2f3685f94c79ecf7b6be0dcb11b72f7d..0a09b062803f6ea15d8b3fa361d60e91e9ccc4b9 100644 --- a/paddle/fluid/inference/api/demo_ci/CMakeLists.txt +++ b/paddle/fluid/inference/api/demo_ci/CMakeLists.txt @@ -36,11 +36,13 @@ include_directories("${PADDLE_LIB_THIRD_PARTY_PATH}protobuf/include") include_directories("${PADDLE_LIB_THIRD_PARTY_PATH}glog/include") include_directories("${PADDLE_LIB_THIRD_PARTY_PATH}gflags/include") include_directories("${PADDLE_LIB_THIRD_PARTY_PATH}xxhash/include") +include_directories("${PADDLE_LIB_THIRD_PARTY_PATH}cryptopp/include") link_directories("${PADDLE_LIB_THIRD_PARTY_PATH}protobuf/lib") link_directories("${PADDLE_LIB_THIRD_PARTY_PATH}glog/lib") link_directories("${PADDLE_LIB_THIRD_PARTY_PATH}gflags/lib") link_directories("${PADDLE_LIB_THIRD_PARTY_PATH}xxhash/lib") +link_directories("${PADDLE_LIB_THIRD_PARTY_PATH}cryptopp/lib") link_directories("${PADDLE_LIB}/paddle/lib") if (WIN32) @@ -145,12 +147,12 @@ if (NOT WIN32) set(EXTERNAL_LIB "-lrt -ldl -lpthread") set(DEPS ${DEPS} ${MATH_LIB} ${MKLDNN_LIB} - glog gflags protobuf xxhash + glog gflags protobuf xxhash cryptopp ${EXTERNAL_LIB}) else() set(DEPS ${DEPS} ${MATH_LIB} ${MKLDNN_LIB} - glog gflags_static libprotobuf xxhash ${EXTERNAL_LIB}) + glog gflags_static libprotobuf xxhash cryptopp-static ${EXTERNAL_LIB}) set(DEPS ${DEPS} shlwapi.lib) endif(NOT WIN32)