diff --git a/CMakeLists.txt b/CMakeLists.txt index 65cb869103c11b32aa5dc90866903157214faa32..adc8bc655eebd6767a9077334921684a2690c02c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,6 +91,7 @@ if(WITH_MKLDNN) endif() add_subdirectory(configure) +add_subdirectory(pdcodegen) add_subdirectory(predictor) add_subdirectory(inferencer-fluid-cpu) add_subdirectory(serving) diff --git a/cmake/generic.cmake b/cmake/generic.cmake index 5dd37fb68403fddff375a4ffa0b6b8bee1559c6a..c5b722fada9b1d5a3d8211f3114722eee040e9dd 100644 --- a/cmake/generic.cmake +++ b/cmake/generic.cmake @@ -793,7 +793,7 @@ function(brpc_library TARGET_NAME) cc_library("${TARGET_NAME}" SRCS "${brpc_library_SRCS}" DEPS "${TARGET_NAME}_proto" "${brpc_library_DEPS}") endfunction() -function(PROTOBUF_GENERATE_SERVING_CPP SRCS HDRS) +function(PROTOBUF_GENERATE_SERVING_CPP FOR_SERVING_SIDE SRCS HDRS ) if(NOT ARGN) message(SEND_ERROR "Error: PROTOBUF_GENERATE_SERVING_CPP() called without any proto files") return() @@ -832,18 +832,33 @@ function(PROTOBUF_GENERATE_SERVING_CPP SRCS HDRS) list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc") list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h") - add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc" - "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h" - COMMAND ${Protobuf_PROTOC_EXECUTABLE} - ARGS --cpp_out=${CMAKE_CURRENT_BINARY_DIR} - --pdcodegen_out=${CMAKE_CURRENT_BINARY_DIR} - --plugin=protoc-gen-pdcodegen=${CMAKE_BINARY_DIR}/predictor/pdcodegen - --proto_path=${CMAKE_SOURCE_DIR}/predictor/proto - ${_protobuf_include_path} ${ABS_FIL} - DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE} - COMMENT "Running Paddle-serving C++ protocol buffer compiler on ${FIL}" - VERBATIM) + message("For serving side " ${FOR_SERVING_SIDE}) + if (${FOR_SERVING_SIDE}) + add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc" + "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h" + COMMAND ${Protobuf_PROTOC_EXECUTABLE} + ARGS --cpp_out=${CMAKE_CURRENT_BINARY_DIR} + --pdcodegen_out=${CMAKE_CURRENT_BINARY_DIR} + --plugin=protoc-gen-pdcodegen=${CMAKE_BINARY_DIR}/pdcodegen/pdcodegen + --proto_path=${CMAKE_SOURCE_DIR}/predictor/proto + ${_protobuf_include_path} ${ABS_FIL} + DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE} + COMMENT "Running Paddle-serving C++ protocol buffer compiler on ${FIL}" + VERBATIM) + else() + add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc" + "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h" + COMMAND ${Protobuf_PROTOC_EXECUTABLE} + ARGS --cpp_out=${CMAKE_CURRENT_BINARY_DIR} + --pdcodegen_out=${CMAKE_CURRENT_BINARY_DIR} + --plugin=protoc-gen-pdcodegen=${CMAKE_BINARY_DIR}/pdcodegen/pdcodegen + ${_protobuf_include_path} ${ABS_FIL} + DEPENDS ${ABS_FIL} ${Protobuf_PROTOC_EXECUTABLE} + COMMENT "Running Paddle-serving C++ protocol buffer compiler on ${FIL}" + VERBATIM) + endif() endforeach() set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE) diff --git a/pdcodegen/CMakeLists.txt b/pdcodegen/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..abb5b5f840872a98c5c5fa2f866697dc30873eb6 --- /dev/null +++ b/pdcodegen/CMakeLists.txt @@ -0,0 +1,17 @@ +include(plugin/CMakeLists.txt) +include(src/CMakeLists.txt) + +PROTOBUF_GENERATE_CPP(pdcodegen_proto_srcs pdcodegen_proto_hdrs + ${CMAKE_SOURCE_DIR}/predictor/proto/pds_option.proto) + +LIST(APPEND pdcodegen_srcs ${pdcodegen_proto_srcs}) + +add_executable(pdcodegen ${pdcodegen_srcs}) +target_link_libraries(pdcodegen protobuf ${PROTOBUF_PROTOC_LIBRARY}) + +# install +install(TARGETS pdcodegen + RUNTIME DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/bin + ARCHIVE DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/lib + LIBRARY DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/so + ) diff --git a/predictor/plugin/CMakeLists.txt b/pdcodegen/plugin/CMakeLists.txt similarity index 100% rename from predictor/plugin/CMakeLists.txt rename to pdcodegen/plugin/CMakeLists.txt diff --git a/predictor/plugin/stl_util-inl.h b/pdcodegen/plugin/stl_util-inl.h similarity index 100% rename from predictor/plugin/stl_util-inl.h rename to pdcodegen/plugin/stl_util-inl.h diff --git a/predictor/plugin/strutil.h b/pdcodegen/plugin/strutil.h similarity index 100% rename from predictor/plugin/strutil.h rename to pdcodegen/plugin/strutil.h diff --git a/predictor/plugin/substitute.cc b/pdcodegen/plugin/substitute.cc similarity index 98% rename from predictor/plugin/substitute.cc rename to pdcodegen/plugin/substitute.cc index b568ee19328f6c0f0b7dc18d717051969b49b939..0ed454481bcfdc43492263adc9ad4a49d8812907 100644 --- a/predictor/plugin/substitute.cc +++ b/pdcodegen/plugin/substitute.cc @@ -45,9 +45,9 @@ // Author: kenton@google.com (Kenton Varda) // #include -#include "predictor/plugin/substitute.h" -#include "predictor/plugin/stl_util-inl.h" -#include "predictor/plugin/strutil.h" +#include "pdcodegen/plugin/substitute.h" +#include "pdcodegen/plugin/stl_util-inl.h" +#include "pdcodegen/plugin/strutil.h" namespace google { namespace protobuf { diff --git a/predictor/plugin/substitute.h b/pdcodegen/plugin/substitute.h similarity index 99% rename from predictor/plugin/substitute.h rename to pdcodegen/plugin/substitute.h index 3d24e6f16bf5943d25552c8d5845e902f33b9fbc..a5bdc1645642ec53db7a73da944a8e6571de54b4 100644 --- a/predictor/plugin/substitute.h +++ b/pdcodegen/plugin/substitute.h @@ -49,7 +49,7 @@ #include // hmmm... // #include -#include "predictor/plugin/strutil.h" +#include "pdcodegen/plugin/strutil.h" #pragma once namespace google { diff --git a/pdcodegen/src/CMakeLists.txt b/pdcodegen/src/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..13a5ce33390442485814eea823c87a0a2d78c3a6 --- /dev/null +++ b/pdcodegen/src/CMakeLists.txt @@ -0,0 +1 @@ +LIST(APPEND pdcodegen_srcs ${CMAKE_CURRENT_LIST_DIR}/pdcodegen.cpp) diff --git a/predictor/src/pdcodegen.cpp b/pdcodegen/src/pdcodegen.cpp similarity index 99% rename from predictor/src/pdcodegen.cpp rename to pdcodegen/src/pdcodegen.cpp index fbfa90049bdcc3da25159fb5a1ec5d51c64ca989..4f0f1c95faac01e49e29066173353bbc863a1b7d 100644 --- a/predictor/src/pdcodegen.cpp +++ b/pdcodegen/src/pdcodegen.cpp @@ -20,9 +20,9 @@ #include "google/protobuf/descriptor.h" #include "google/protobuf/io/printer.h" #include "google/protobuf/io/zero_copy_stream.h" -#include "predictor/pds_option.pb.h" -#include "predictor/plugin/strutil.h" -#include "predictor/plugin/substitute.h" +#include "pdcodegen/pds_option.pb.h" +#include "pdcodegen/plugin/strutil.h" +#include "pdcodegen/plugin/substitute.h" using std::string; using google::protobuf::Descriptor; using google::protobuf::FileDescriptor; diff --git a/predictor/CMakeLists.txt b/predictor/CMakeLists.txt index 57156f944baf4710582a24fa634410f9427890eb..c793e28c0f4030935a007c0b37b7b3fa5db1e3e0 100644 --- a/predictor/CMakeLists.txt +++ b/predictor/CMakeLists.txt @@ -3,12 +3,9 @@ include(common/CMakeLists.txt) include(op/CMakeLists.txt) include(mempool/CMakeLists.txt) include(framework/CMakeLists.txt) -include(plugin/CMakeLists.txt) +#include(plugin/CMakeLists.txt) include(src/CMakeLists.txt) -add_executable(pdcodegen ${pdcodegen_srcs}) -target_link_libraries(pdcodegen protobuf ${PROTOBUF_PROTOC_LIBRARY}) - add_library(pdserving ${pdserving_srcs}) set_source_files_properties( ${pdserving_srcs} @@ -20,7 +17,7 @@ target_link_libraries(pdserving brpc protobuf boost leveldb configure -lpthread -lcrypto -lm -lrt -lssl -ldl -lz) # install -install(TARGETS pdserving pdcodegen +install(TARGETS pdserving RUNTIME DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/bin ARCHIVE DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/lib LIBRARY DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/so diff --git a/predictor/plugin/pdcodegen b/predictor/plugin/pdcodegen deleted file mode 100755 index bb81217121a15b99cda8a320f357f716357f96c5..0000000000000000000000000000000000000000 Binary files a/predictor/plugin/pdcodegen and /dev/null differ diff --git a/predictor/proto/CMakeLists.txt b/predictor/proto/CMakeLists.txt index 9f060450b68fd6d4a8f1b9a11fd76bac41d527b3..773b5bfccea2a787409eb9be4b5722dd85f5fe61 100644 --- a/predictor/proto/CMakeLists.txt +++ b/predictor/proto/CMakeLists.txt @@ -1,7 +1,7 @@ PROTOBUF_GENERATE_CPP(pdcodegen_proto_srcs pdcodegen_proto_hdrs ${CMAKE_CURRENT_LIST_DIR}/pds_option.proto) -LIST(APPEND pdcodegen_srcs ${pdcodegen_proto_srcs}) +LIST(APPEND pdserving_srcs ${pdcodegen_proto_srcs}) LIST(APPEND protofiles ${CMAKE_CURRENT_LIST_DIR}/./builtin_format.proto @@ -9,5 +9,5 @@ LIST(APPEND protofiles ${CMAKE_CURRENT_LIST_DIR}/./xrecord_format.proto ) -PROTOBUF_GENERATE_SERVING_CPP(PROTO_SRCS PROTO_HDRS ${protofiles}) +PROTOBUF_GENERATE_SERVING_CPP(TRUE PROTO_SRCS PROTO_HDRS ${protofiles}) LIST(APPEND pdserving_srcs ${PROTO_SRCS} ${pdcodegen_proto_srcs}) diff --git a/predictor/proto/builtin_format.proto b/predictor/proto/builtin_format.proto index 6666f6479393a4912ed23d02c24585a3caf6e1b0..8f0d1d8f01ffa6f026271a1f3d20b08ae072cc77 100644 --- a/predictor/proto/builtin_format.proto +++ b/predictor/proto/builtin_format.proto @@ -13,7 +13,6 @@ // limitations under the License. syntax = "proto2"; -import "pds_option.proto"; package baidu.paddle_serving.predictor.format; // dense format diff --git a/predictor/src/CMakeLists.txt b/predictor/src/CMakeLists.txt index d6e5bf98148aba497993f7d894319fdf7917e34d..91d460e6cf3dda5e5266992818324d684bc25154 100644 --- a/predictor/src/CMakeLists.txt +++ b/predictor/src/CMakeLists.txt @@ -1,2 +1 @@ -LIST(APPEND pdcodegen_srcs ${CMAKE_CURRENT_LIST_DIR}/pdcodegen.cpp) LIST(APPEND pdserving_srcs ${CMAKE_CURRENT_LIST_DIR}/pdserving.cpp) diff --git a/sdk-cpp/CMakeLists.txt b/sdk-cpp/CMakeLists.txt index 22486e9c7efce64007231178cc8fd34c741c95e8..fd548764dd41f88b06d546e80bbade0e69cedf33 100644 --- a/sdk-cpp/CMakeLists.txt +++ b/sdk-cpp/CMakeLists.txt @@ -18,7 +18,7 @@ include(src/CMakeLists.txt) include(proto/CMakeLists.txt) add_library(sdk-cpp ${sdk_cpp_srcs}) add_dependencies(sdk-cpp pdcodegen configure) -target_link_libraries(sdk-cpp pdserving brpc configure protobuf leveldb) +target_link_libraries(sdk-cpp brpc configure protobuf leveldb) target_include_directories(sdk-cpp PUBLIC ${CMAKE_BINARY_DIR}/predictor/) @@ -97,3 +97,6 @@ install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/conf DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/demo/client/text_classification/) install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/data/text_classification DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/demo/client/text_classification/data) + +install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include + DESTINATION ${PADDLE_SERVING_INSTALL_DIR}/) diff --git a/sdk-cpp/proto/CMakeLists.txt b/sdk-cpp/proto/CMakeLists.txt index 20df8658e43d3eb306cac9932ded6cbb175c86a8..0807eb304fe5ad0c29695af37fb23a743ecee466 100644 --- a/sdk-cpp/proto/CMakeLists.txt +++ b/sdk-cpp/proto/CMakeLists.txt @@ -1,3 +1,5 @@ FILE(GLOB protos ${CMAKE_CURRENT_LIST_DIR}/*.proto) -PROTOBUF_GENERATE_SERVING_CPP(PROTO_SRCS PROTO_HDRS ${protos}) +list(APPEND protos ${CMAKE_SOURCE_DIR}/predictor/proto/pds_option.proto + ${CMAKE_SOURCE_DIR}/predictor/proto/builtin_format.proto) +PROTOBUF_GENERATE_SERVING_CPP(FALSE PROTO_SRCS PROTO_HDRS ${protos}) LIST(APPEND sdk_cpp_srcs ${PROTO_SRCS}) diff --git a/serving/proto/CMakeLists.txt b/serving/proto/CMakeLists.txt index dcf26f7dd0eb54ec52dbdb5915fd70c22aff454e..5b7b7cb37063421462ae525aa5741ed5d91f0be1 100644 --- a/serving/proto/CMakeLists.txt +++ b/serving/proto/CMakeLists.txt @@ -7,5 +7,5 @@ LIST(APPEND protofiles ${CMAKE_CURRENT_LIST_DIR}/text_classification.proto ) -PROTOBUF_GENERATE_SERVING_CPP(PROTO_SRCS PROTO_HDRS ${protofiles}) +PROTOBUF_GENERATE_SERVING_CPP(TRUE PROTO_SRCS PROTO_HDRS ${protofiles}) LIST(APPEND serving_srcs ${PROTO_SRCS})