未验证 提交 3b8f0a64 编写于 作者: M MRXLT 提交者: GitHub

Encryption infer (#25119)

* add encrypt api for inference lib
上级 46214e59
...@@ -89,6 +89,8 @@ ...@@ -89,6 +89,8 @@
# including binary directory for generated headers. # including binary directory for generated headers.
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
# including io directory for inference lib paddle_api.h
include_directories("${PADDLE_SOURCE_DIR}/paddle/fluid/framework/io")
if(NOT APPLE) if(NOT APPLE)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
......
...@@ -107,6 +107,11 @@ function(copy_part_of_thrid_party TARGET DST) ...@@ -107,6 +107,11 @@ function(copy_part_of_thrid_party TARGET DST)
SRCS ${GLOG_INCLUDE_DIR} ${GLOG_LIBRARIES} SRCS ${GLOG_INCLUDE_DIR} ${GLOG_LIBRARIES}
DSTS ${dst_dir} ${dst_dir}/lib) DSTS ${dst_dir} ${dst_dir}/lib)
set(dst_dir "${DST}/third_party/install/cryptopp")
copy(${TARGET}
SRCS ${CRYPTOPP_INCLUDE_DIR} ${CRYPTOPP_LIBRARIES}
DSTS ${dst_dir} ${dst_dir}/lib)
set(dst_dir "${DST}/third_party/install/xxhash") set(dst_dir "${DST}/third_party/install/xxhash")
copy(${TARGET} copy(${TARGET}
SRCS ${XXHASH_INCLUDE_DIR} ${XXHASH_LIBRARIES} SRCS ${XXHASH_INCLUDE_DIR} ${XXHASH_LIBRARIES}
...@@ -178,7 +183,10 @@ endif() ...@@ -178,7 +183,10 @@ endif()
copy(inference_lib_dist copy(inference_lib_dist
SRCS ${CMAKE_BINARY_DIR}/paddle/fluid/framework/framework.pb.h SRCS ${CMAKE_BINARY_DIR}/paddle/fluid/framework/framework.pb.h
DSTS ${FLUID_INFERENCE_INSTALL_DIR}/paddle/include/internal) DSTS ${FLUID_INFERENCE_INSTALL_DIR}/paddle/include/internal)
copy(inference_lib_dist
SRCS ${CMAKE_BINARY_DIR}/../paddle/fluid/framework/io/crypto/cipher.h
DSTS ${FLUID_INFERENCE_INSTALL_DIR}/paddle/include/crypto/)
include_directories(${CMAKE_BINARY_DIR}/../paddle/fluid/framework/io)
# CAPI inference library for only inference # CAPI inference library for only inference
set(FLUID_INFERENCE_C_INSTALL_DIR "${CMAKE_BINARY_DIR}/fluid_inference_c_install_dir" CACHE STRING set(FLUID_INFERENCE_C_INSTALL_DIR "${CMAKE_BINARY_DIR}/fluid_inference_c_install_dir" CACHE STRING
"A path setting CAPI fluid inference shared") "A path setting CAPI fluid inference shared")
......
...@@ -18,9 +18,9 @@ limitations under the License. */ ...@@ -18,9 +18,9 @@ limitations under the License. */
#include <glog/logging.h> #include <glog/logging.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <fstream>
#include <string> #include <string>
#include <vector> #include <vector>
#include "paddle/fluid/framework/io/crypto/cipher.h" #include "paddle/fluid/framework/io/crypto/cipher.h"
#include "paddle/fluid/framework/io/crypto/cipher_utils.h" #include "paddle/fluid/framework/io/crypto/cipher_utils.h"
......
...@@ -16,7 +16,9 @@ ...@@ -16,7 +16,9 @@
#include "paddle/fluid/framework/io/crypto/aes_cipher.h" #include "paddle/fluid/framework/io/crypto/aes_cipher.h"
#include "paddle/fluid/framework/io/crypto/cipher_utils.h" #include "paddle/fluid/framework/io/crypto/cipher_utils.h"
#include "paddle/fluid/platform/enforce.h" #include "paddle/fluid/platform/enforce.h"
#ifdef ON_INFER
#include "paddle/fluid/inference/api/paddle_api.h"
#endif
namespace paddle { namespace paddle {
namespace framework { namespace framework {
...@@ -57,4 +59,9 @@ std::shared_ptr<Cipher> CipherFactory::CreateCipher( ...@@ -57,4 +59,9 @@ std::shared_ptr<Cipher> CipherFactory::CreateCipher(
} }
} // namespace framework } // namespace framework
#ifdef ON_INFER
std::shared_ptr<framework::Cipher> MakeCipher(const std::string& config_file) {
return framework::CipherFactory::CreateCipher(config_file);
}
#endif
} // namespace paddle } // namespace paddle
...@@ -46,6 +46,5 @@ class CipherFactory { ...@@ -46,6 +46,5 @@ class CipherFactory {
CipherFactory() = default; CipherFactory() = default;
static std::shared_ptr<Cipher> CreateCipher(const std::string& config_file); static std::shared_ptr<Cipher> CreateCipher(const std::string& config_file);
}; };
} // namespace framework } // namespace framework
} // namespace paddle } // namespace paddle
...@@ -14,11 +14,9 @@ ...@@ -14,11 +14,9 @@
#pragma once #pragma once
#include <sstream>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include "paddle/fluid/platform/enforce.h"
namespace paddle { namespace paddle {
namespace framework { namespace framework {
......
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
#include "crypto/cipher.h"
#include "paddle_infer_declare.h" // NOLINT #include "paddle_infer_declare.h" // NOLINT
/*! \namespace paddle
/*! \namespace paddle */
*/
namespace paddle { namespace paddle {
/// \brief Paddle data type. /// \brief Paddle data type.
...@@ -431,4 +431,6 @@ PD_INFER_DECL std::string get_version(); ...@@ -431,4 +431,6 @@ PD_INFER_DECL std::string get_version();
PD_INFER_DECL std::string UpdateDllFlag(const char* name, const char* value); PD_INFER_DECL std::string UpdateDllFlag(const char* name, const char* value);
PD_INFER_DECL std::shared_ptr<framework::Cipher> MakeCipher(
const std::string& config_file);
} // namespace paddle } // namespace paddle
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册