Skip to content

Commit 6330fc9

Browse files
authored
cherry-pick (#31279)
1 parent 777d1a4 commit 6330fc9

File tree

7 files changed

+26
-11
lines changed

7 files changed

+26
-11
lines changed

cmake/external/xpu.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ endif()
44

55
INCLUDE(ExternalProject)
66
SET(XPU_PROJECT "extern_xpu")
7+
SET(XPU_API_LIB_NAME "libxpuapi.so")
8+
SET(XPU_RT_LIB_NAME "libxpurt.so")
79

810
if(NOT XPU_SDK_ROOT)
911
if (WITH_AARCH64)
@@ -20,8 +22,6 @@ if(NOT XPU_SDK_ROOT)
2022
SET(XPU_API_INC_DIR "${THIRD_PARTY_PATH}/install/xpu/include")
2123
SET(XPU_LIB_DIR "${THIRD_PARTY_PATH}/install/xpu/lib")
2224

23-
SET(XPU_API_LIB_NAME "libxpuapi.so")
24-
SET(XPU_RT_LIB_NAME "libxpurt.so")
2525
SET(XPU_API_LIB "${XPU_LIB_DIR}/${XPU_API_LIB_NAME}")
2626
SET(XPU_RT_LIB "${XPU_LIB_DIR}/${XPU_RT_LIB_NAME}")
2727

cmake/third_party.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ endif (WITH_LITE)
322322

323323
if (WITH_CRYPTO)
324324
include(external/cryptopp) # download, build, install cryptopp
325+
add_definitions(-DPADDLE_WITH_CRYPTO)
325326
endif (WITH_CRYPTO)
326327

327328
add_custom_target(third_party ALL DEPENDS ${third_party_deps})

paddle/fluid/framework/io/crypto/cipher.cc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,4 @@ std::shared_ptr<Cipher> CipherFactory::CreateCipher(
5656
}
5757

5858
} // namespace framework
59-
60-
std::shared_ptr<framework::Cipher> MakeCipher(const std::string& config_file) {
61-
return framework::CipherFactory::CreateCipher(config_file);
62-
}
63-
6459
} // namespace paddle

paddle/fluid/inference/api/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ endif()
3030
cc_library(analysis_config SRCS analysis_config.cc DEPS ${mkldnn_quantizer_cfg} lod_tensor paddle_pass_builder)
3131
cc_library(paddle_pass_builder SRCS paddle_pass_builder.cc)
3232

33-
cc_library(paddle_inference_api SRCS api.cc api_impl.cc helper.cc DEPS lod_tensor scope reset_tensor_array
34-
analysis_config zero_copy_tensor trainer_desc_proto)
33+
if(WITH_CRYPTO)
34+
cc_library(paddle_inference_api SRCS api.cc api_impl.cc helper.cc DEPS lod_tensor scope reset_tensor_array
35+
analysis_config zero_copy_tensor trainer_desc_proto paddle_crypto)
36+
else()
37+
cc_library(paddle_inference_api SRCS api.cc api_impl.cc helper.cc DEPS lod_tensor scope reset_tensor_array
38+
analysis_config zero_copy_tensor trainer_desc_proto)
39+
endif()
40+
3541

3642
if(WIN32)
3743
target_link_libraries(paddle_inference_api gflags)

paddle/fluid/inference/api/api.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,10 @@ std::string UpdateDllFlag(const char *name, const char *value) {
146146
return ret;
147147
}
148148

149+
#ifdef PADDLE_WITH_CRYPTO
150+
std::shared_ptr<framework::Cipher> MakeCipher(const std::string &config_file) {
151+
return framework::CipherFactory::CreateCipher(config_file);
152+
}
153+
#endif
154+
149155
} // namespace paddle

paddle/fluid/inference/api/api_tester.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,9 @@ TEST(paddle_inference_api, AnalysisConfigCopyCtor) {
9191
CHECK_NE(ps, delete_pass);
9292
}
9393
}
94+
95+
#ifdef PADDLE_WITH_CRYPTO
96+
TEST(paddle_inference_api, crypto) { paddle::MakeCipher(""); }
97+
#endif
98+
9499
} // namespace paddle

paddle/fluid/inference/api/demo_ci/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ include_directories("${PADDLE_LIB_THIRD_PARTY_PATH}protobuf/include")
3636
include_directories("${PADDLE_LIB_THIRD_PARTY_PATH}glog/include")
3737
include_directories("${PADDLE_LIB_THIRD_PARTY_PATH}gflags/include")
3838
include_directories("${PADDLE_LIB_THIRD_PARTY_PATH}xxhash/include")
39+
include_directories("${PADDLE_LIB_THIRD_PARTY_PATH}cryptopp/include")
3940

4041
link_directories("${PADDLE_LIB_THIRD_PARTY_PATH}protobuf/lib")
4142
link_directories("${PADDLE_LIB_THIRD_PARTY_PATH}glog/lib")
4243
link_directories("${PADDLE_LIB_THIRD_PARTY_PATH}gflags/lib")
4344
link_directories("${PADDLE_LIB_THIRD_PARTY_PATH}xxhash/lib")
45+
link_directories("${PADDLE_LIB_THIRD_PARTY_PATH}cryptopp/lib")
4446
link_directories("${PADDLE_LIB}/paddle/lib")
4547

4648
if (WIN32)
@@ -145,12 +147,12 @@ if (NOT WIN32)
145147
set(EXTERNAL_LIB "-lrt -ldl -lpthread")
146148
set(DEPS ${DEPS}
147149
${MATH_LIB} ${MKLDNN_LIB}
148-
glog gflags protobuf xxhash
150+
glog gflags protobuf xxhash cryptopp
149151
${EXTERNAL_LIB})
150152
else()
151153
set(DEPS ${DEPS}
152154
${MATH_LIB} ${MKLDNN_LIB}
153-
glog gflags_static libprotobuf xxhash ${EXTERNAL_LIB})
155+
glog gflags_static libprotobuf xxhash cryptopp-static ${EXTERNAL_LIB})
154156
set(DEPS ${DEPS} shlwapi.lib)
155157
endif(NOT WIN32)
156158

0 commit comments

Comments
 (0)