diff --git a/cmake/generic.cmake b/cmake/generic.cmake index a47ffa71b6c674e019e9fe895d2bda113f765079..69f4ccae88471dfd5caf1ef2410c5aeefab7db3c 100644 --- a/cmake/generic.cmake +++ b/cmake/generic.cmake @@ -89,6 +89,8 @@ # including binary directory for generated headers. 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) find_package(Threads REQUIRED) diff --git a/cmake/inference_lib.cmake b/cmake/inference_lib.cmake index 8c2549cc0516f88093fa432848516e39a38f0959..6fc81f2387b78cce10f9c099a022b2372993c4f9 100644 --- a/cmake/inference_lib.cmake +++ b/cmake/inference_lib.cmake @@ -107,6 +107,11 @@ function(copy_part_of_thrid_party TARGET DST) SRCS ${GLOG_INCLUDE_DIR} ${GLOG_LIBRARIES} 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") copy(${TARGET} SRCS ${XXHASH_INCLUDE_DIR} ${XXHASH_LIBRARIES} @@ -178,7 +183,10 @@ endif() copy(inference_lib_dist SRCS ${CMAKE_BINARY_DIR}/paddle/fluid/framework/framework.pb.h 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 set(FLUID_INFERENCE_C_INSTALL_DIR "${CMAKE_BINARY_DIR}/fluid_inference_c_install_dir" CACHE STRING "A path setting CAPI fluid inference shared") diff --git a/paddle/fluid/framework/io/crypto/aes_cipher_test.cc b/paddle/fluid/framework/io/crypto/aes_cipher_test.cc index 3ba55f4f45561a80d712ae064f976c270be340dd..393c1bffdd0d5778fe5c33b2bc98a9d8a78596b0 100644 --- a/paddle/fluid/framework/io/crypto/aes_cipher_test.cc +++ b/paddle/fluid/framework/io/crypto/aes_cipher_test.cc @@ -18,9 +18,9 @@ limitations under the License. */ #include #include +#include #include #include - #include "paddle/fluid/framework/io/crypto/cipher.h" #include "paddle/fluid/framework/io/crypto/cipher_utils.h" diff --git a/paddle/fluid/framework/io/crypto/cipher.cc b/paddle/fluid/framework/io/crypto/cipher.cc index eca175c020cb6f85eac2970aa9734c0a6850ebef..c258028e25066d14820017edaaa103b39c57158d 100644 --- a/paddle/fluid/framework/io/crypto/cipher.cc +++ b/paddle/fluid/framework/io/crypto/cipher.cc @@ -16,7 +16,9 @@ #include "paddle/fluid/framework/io/crypto/aes_cipher.h" #include "paddle/fluid/framework/io/crypto/cipher_utils.h" #include "paddle/fluid/platform/enforce.h" - +#ifdef ON_INFER +#include "paddle/fluid/inference/api/paddle_api.h" +#endif namespace paddle { namespace framework { @@ -57,4 +59,9 @@ std::shared_ptr CipherFactory::CreateCipher( } } // namespace framework +#ifdef ON_INFER +std::shared_ptr MakeCipher(const std::string& config_file) { + return framework::CipherFactory::CreateCipher(config_file); +} +#endif } // namespace paddle diff --git a/paddle/fluid/framework/io/crypto/cipher.h b/paddle/fluid/framework/io/crypto/cipher.h index 9072cb1180d5c579b9cca9ebee3dbe810ebea2cf..fc31653c2402eaafc8f28697bcec805d694a2a07 100644 --- a/paddle/fluid/framework/io/crypto/cipher.h +++ b/paddle/fluid/framework/io/crypto/cipher.h @@ -46,6 +46,5 @@ class CipherFactory { CipherFactory() = default; static std::shared_ptr CreateCipher(const std::string& config_file); }; - } // namespace framework } // namespace paddle diff --git a/paddle/fluid/framework/io/crypto/cipher_utils.h b/paddle/fluid/framework/io/crypto/cipher_utils.h index 0533275798f3bf0870fdb0989c96852fffc07628..936f62f6ba65cfe26be56ed2dd828f1e42e8d1b2 100644 --- a/paddle/fluid/framework/io/crypto/cipher_utils.h +++ b/paddle/fluid/framework/io/crypto/cipher_utils.h @@ -14,11 +14,9 @@ #pragma once +#include #include #include - -#include "paddle/fluid/platform/enforce.h" - namespace paddle { namespace framework { diff --git a/paddle/fluid/inference/api/paddle_api.h b/paddle/fluid/inference/api/paddle_api.h index d871661497a243bc22903f4d24fe4e1e6d2517db..bf243bf9a45ebb67a0b6bc356ac2697decd1e300 100644 --- a/paddle/fluid/inference/api/paddle_api.h +++ b/paddle/fluid/inference/api/paddle_api.h @@ -27,10 +27,10 @@ #include #include #include +#include "crypto/cipher.h" #include "paddle_infer_declare.h" // NOLINT - -/*! \namespace paddle - */ + /*! \namespace paddle + */ namespace paddle { /// \brief Paddle data type. @@ -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::shared_ptr MakeCipher( + const std::string& config_file); } // namespace paddle