Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
cc1c24d7
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
cc1c24d7
编写于
2月 15, 2019
作者:
W
wangguibao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libpdserving & libpdclient
上级
00986291
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
132 addition
and
84 deletion
+132
-84
cmake/flags.cmake
cmake/flags.cmake
+0
-1
cmake/generic.cmake
cmake/generic.cmake
+57
-0
predictor/CMakeLists.txt
predictor/CMakeLists.txt
+34
-4
predictor/common/CMakeLists.txt
predictor/common/CMakeLists.txt
+2
-1
predictor/framework/CMakeLists.txt
predictor/framework/CMakeLists.txt
+2
-1
predictor/framework/logger.h
predictor/framework/logger.h
+0
-35
predictor/op/CMakeLists.txt
predictor/op/CMakeLists.txt
+2
-1
predictor/plugin/CMakeLists.txt
predictor/plugin/CMakeLists.txt
+2
-0
predictor/proto/CMakeLists.txt
predictor/proto/CMakeLists.txt
+20
-3
predictor/src/CMakeLists.txt
predictor/src/CMakeLists.txt
+3
-0
predictor/src/pdclient.cpp
predictor/src/pdclient.cpp
+4
-23
predictor/src/pdserving.cpp
predictor/src/pdserving.cpp
+6
-15
未找到文件。
cmake/flags.cmake
浏览文件 @
cc1c24d7
...
...
@@ -116,7 +116,6 @@ if (NOT WIN32)
set
(
COMMON_FLAGS
-fPIC
-fno-omit-frame-pointer
-Werror
-Wall
-Wextra
-Wnon-virtual-dtor
...
...
cmake/generic.cmake
浏览文件 @
cc1c24d7
...
...
@@ -792,3 +792,60 @@ function(brpc_library TARGET_NAME)
cc_library
(
"
${
TARGET_NAME
}
_proto"
SRCS
"
${
brpc_proto_srcs
}
"
)
cc_library
(
"
${
TARGET_NAME
}
"
SRCS
"
${
brpc_library_SRCS
}
"
DEPS
"
${
TARGET_NAME
}
_proto"
"
${
brpc_library_DEPS
}
"
)
endfunction
()
function
(
PROTOBUF_GENERATE_SERVING_CPP SRCS HDRS
)
if
(
NOT ARGN
)
message
(
SEND_ERROR
"Error: PROTOBUF_GENERATE_SERVING_CPP() called without any proto files"
)
return
()
endif
()
if
(
PROTOBUF_GENERATE_CPP_APPEND_PATH
)
# This variable is common for all types of output.
# Create an include path for each file specified
foreach
(
FIL
${
ARGN
}
)
get_filename_component
(
ABS_FIL
${
FIL
}
ABSOLUTE
)
get_filename_component
(
ABS_PATH
${
ABS_FIL
}
PATH
)
list
(
FIND _protobuf_include_path
${
ABS_PATH
}
_contains_already
)
if
(
${
_contains_already
}
EQUAL -1
)
list
(
APPEND _protobuf_include_path -I
${
ABS_PATH
}
)
endif
()
endforeach
()
else
()
set
(
_protobuf_include_path -I
${
CMAKE_CURRENT_SOURCE_DIR
}
)
endif
()
if
(
DEFINED PROTOBUF_IMPORT_DIRS
)
foreach
(
DIR
${
Protobuf_IMPORT_DIRS
}
)
get_filename_component
(
ABS_PATH
${
DIR
}
ABSOLUTE
)
list
(
FIND _protobuf_include_path
${
ABS_PATH
}
_contains_already
)
if
(
${
_contains_already
}
EQUAL -1
)
list
(
APPEND _protobuf_include_path -I
${
ABS_PATH
}
)
endif
()
endforeach
()
endif
()
set
(
${
SRCS
}
)
set
(
${
HDRS
}
)
foreach
(
FIL
${
ARGN
}
)
get_filename_component
(
ABS_FIL
${
FIL
}
ABSOLUTE
)
get_filename_component
(
FIL_WE
${
FIL
}
NAME_WE
)
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 --pdcodegen_out=
${
CMAKE_CURRENT_BINARY_DIR
}
--plugin=protoc-gen-pdcodegen=
${
CMAKE_CURRENT_BINARY_DIR
}
/pdcodegen
--proto_path=.
${
_protobuf_include_path
}
${
ABS_FIL
}
DEPENDS
${
ABS_FIL
}
${
Protobuf_PROTOC_EXECUTABLE
}
COMMENT
"Running Paddle-serving C++ protocol buffer compiler on
${
FIL
}
"
VERBATIM
)
endforeach
()
set_source_files_properties
(
${${
SRCS
}}
${${
HDRS
}}
PROPERTIES GENERATED TRUE
)
set
(
${
SRCS
}
${${
SRCS
}}
PARENT_SCOPE
)
set
(
${
HDRS
}
${${
HDRS
}}
PARENT_SCOPE
)
endfunction
()
predictor/CMakeLists.txt
浏览文件 @
cc1c24d7
...
...
@@ -2,13 +2,41 @@ include(proto/CMakeLists.txt)
include
(
common/CMakeLists.txt
)
include
(
op/CMakeLists.txt
)
include
(
framework/CMakeLists.txt
)
add_library
(
predictor
${
predictor_srcs
}
)
include
(
plugin/CMakeLists.txt
)
include
(
src/CMakeLists.txt
)
add_executable
(
pdcodegen
${
pdcodegen_srcs
}
)
target_link_libraries
(
pdcodegen protobuf
${
PROTOBUF_PROTOC_LIBRARY
}
)
target_include_directories
(
pdcodegen PUBLIC
${
CMAKE_CURRENT_LIST_DIR
}
/
${
CMAKE_CURRENT_BINARY_DIR
}
/
)
add_library
(
pdserving
${
pdserving_srcs
}
)
set_source_files_properties
(
${
pdserving_srcs
}
PROPERTIES
COMPILE_FLAGS
"-Wno-strict-aliasing -Wno-unused-variable -Wno-non-virtual-dtor -Wno-error=non-virtual-dtor -Wno-error=delete-non-virtual-dtor"
)
add_dependencies
(
pdserving protobuf boost brpc pdcodegen
)
target_include_directories
(
pdserving PUBLIC
${
CMAKE_CURRENT_LIST_DIR
}
/
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
CMAKE_CURRENT_LIST_DIR
}
/../configure
${
CMAKE_CURRENT_LIST_DIR
}
/../mempool
${
CMAKE_CURRENT_LIST_DIR
}
/../spreg
${
CMAKE_CURRENT_LIST_DIR
}
/../ullib/include
${
CMAKE_CURRENT_BINARY_DIR
}
/../bsl/include
)
target_link_libraries
(
pdserving -lpthread -lcrypto -lm -lrt -lssl -ldl -lz
)
add_library
(
pdclient
${
pdclient_srcs
}
)
set_source_files_properties
(
${
p
redictor
_srcs
}
${
p
dclient
_srcs
}
PROPERTIES
COMPILE_FLAGS
"-Wno-strict-aliasing -Wno-unused-variable -Wno-non-virtual-dtor -Wno-error=non-virtual-dtor -Wno-error=delete-non-virtual-dtor"
)
add_dependencies
(
predictor protobuf boost brpc
)
target_include_directories
(
predictor PUBLIC
add_dependencies
(
pdclient protobuf boost brpc pdcodegen
)
target_include_directories
(
pdclient PUBLIC
${
CMAKE_CURRENT_LIST_DIR
}
/
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
CMAKE_CURRENT_LIST_DIR
}
/../configure
...
...
@@ -16,3 +44,5 @@ target_include_directories(predictor PUBLIC
${
CMAKE_CURRENT_LIST_DIR
}
/../spreg
${
CMAKE_CURRENT_LIST_DIR
}
/../ullib/include
${
CMAKE_CURRENT_BINARY_DIR
}
/../bsl/include
)
target_link_libraries
(
pdclient -lpthread -lcrypto -lm -lrt -lssl -ldl -lz
)
predictor/common/CMakeLists.txt
浏览文件 @
cc1c24d7
FILE
(
GLOB common_srcs
${
CMAKE_CURRENT_LIST_DIR
}
/*.cpp
)
LIST
(
APPEND predictor_srcs
${
common_srcs
}
)
LIST
(
APPEND pdserving_srcs
${
common_srcs
}
)
LIST
(
APPEND pdclient_srcs
${
common_srcs
}
)
predictor/framework/CMakeLists.txt
浏览文件 @
cc1c24d7
FILE
(
GLOB framework_srcs
${
CMAKE_CURRENT_LIST_DIR
}
/*.cpp
)
LIST
(
APPEND predictor_srcs
${
framework_srcs
}
)
LIST
(
APPEND pdserving_srcs
${
framework_srcs
}
)
LIST
(
APPEND pclient_srcs
${
framework_srcs
}
)
predictor/framework/logger.h
已删除
100644 → 0
浏览文件 @
00986291
#ifndef BAIDU_PADDLE_SERVING_PREDICTOR_LOGGER_H
#define BAIDU_PADDLE_SERVING_PREDICTOR_LOGGER_H
#include <butil/comlog_sink.h>
namespace
baidu
{
namespace
paddle_serving
{
namespace
predictor
{
class
LoggerWrapper
{
public:
static
LoggerWrapper
&
instance
()
{
static
LoggerWrapper
lw
;
return
lw
;
}
int
initialize
(
const
std
::
string
&
path
,
const
std
::
string
&
name
)
{
if
(
com_loadlog
(
path
.
c_str
(),
name
.
c_str
())
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to com_loadlog from: "
<<
path
<<
"/"
<<
name
;
return
-
1
;
}
return
0
;
}
int
finalize
()
{
return
0
;
}
};
}
}
}
#endif
predictor/op/CMakeLists.txt
浏览文件 @
cc1c24d7
FILE
(
GLOB op_srcs
${
CMAKE_CURRENT_LIST_DIR
}
/*.cpp
)
LIST
(
APPEND predictor_srcs
${
op_srcs
}
)
LIST
(
APPEND pdserving_srcs
${
op_srcs
}
)
LIST
(
APPEND pdclient_srcs
${
op_srcs
}
)
predictor/plugin/CMakeLists.txt
0 → 100644
浏览文件 @
cc1c24d7
FILE
(
GLOB plugin_srcs
${
CMAKE_CURRENT_LIST_DIR
}
/*.cc
)
LIST
(
APPEND pdcodegen_srcs
${
plugin_srcs
}
)
predictor/proto/CMakeLists.txt
浏览文件 @
cc1c24d7
FILE
(
GLOB protofiles
"
${
CMAKE_CURRENT_LIST_DIR
}
/*.proto"
)
protobuf_generate_cpp
(
PROTO_SRCS PROTO_HDRS
${
protofiles
}
)
LIST
(
APPEND predictor_srcs
${
PROTO_SRCS
}
)
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 protofiles
${
CMAKE_CURRENT_LIST_DIR
}
/./builtin_format.proto
${
CMAKE_CURRENT_LIST_DIR
}
/./dense_service.proto
${
CMAKE_CURRENT_LIST_DIR
}
/./echo_service.proto
${
CMAKE_CURRENT_LIST_DIR
}
/./image_classification.proto
${
CMAKE_CURRENT_LIST_DIR
}
/./int64tensor_service.proto
${
CMAKE_CURRENT_LIST_DIR
}
/./msg_data.proto
${
CMAKE_CURRENT_LIST_DIR
}
/./sparse_service.proto
${
CMAKE_CURRENT_LIST_DIR
}
/./xrecord_format.proto
)
# PROTOBUF_GENERATE_SERVING_CPP(PROTO_SRCS PROTO_HDRS ${protofiles})
PROTOBUF_GENERATE_CPP
(
PROTO_SRCS PROTO_HDRS
${
protofiles
}
)
LIST
(
APPEND pdserving_srcs
${
PROTO_SRCS
}
${
pdcodegen_proto_srcs
}
)
LIST
(
APPEND pdclient_srcs
${
PROTO_SRCS
}
${
pdcodegen_proto_srcs
}
)
predictor/src/CMakeLists.txt
0 → 100644
浏览文件 @
cc1c24d7
LIST
(
APPEND pdcodegen_srcs
${
CMAKE_CURRENT_LIST_DIR
}
/pdcodegen.cpp
)
LIST
(
APPEND pdserving_srcs
${
CMAKE_CURRENT_LIST_DIR
}
/pdserving.cpp
)
LIST
(
APPEND pdclient_srcs
${
CMAKE_CURRENT_LIST_DIR
}
/pdclient.cpp
)
predictor/src/pdclient.cpp
浏览文件 @
cc1c24d7
...
...
@@ -24,11 +24,9 @@
#include "common/utils.h"
#include "common/inner_common.h"
#include "common/constant.h"
#include "
framework/logger
.h"
#include "
butil/logging
.h"
DEFINE_string
(
attachment
,
"foo"
,
"Carry this along with requests"
);
DEFINE_bool
(
auth
,
false
,
"Enable Giano authentication"
);
DEFINE_string
(
auth_group
,
"g_guest"
,
"Giano Group"
);
DEFINE_string
(
protocol
,
"baidu_std"
,
"Protocol type. Defined in protocol/baidu/rpc/options.proto"
);
DEFINE_bool
(
compress
,
true
,
"Enable compression"
);
//DEFINE_string(protocol, "http", "Protocol type. Defined in protocol/baidu/rpc/options.proto");
...
...
@@ -42,7 +40,6 @@ DEFINE_string(http_content_type, "application/json", "Content type of http reque
using
baidu
::
paddle_serving
::
predictor
::
FLAGS_logger_path
;
using
baidu
::
paddle_serving
::
predictor
::
FLAGS_logger_file
;
using
baidu
::
paddle_serving
::
predictor
::
LoggerWrapper
;
namespace
dense_format
{
...
...
@@ -372,24 +369,7 @@ int main(int argc, char* argv[]) {
google
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
// initialize logger instance
if
(
LoggerWrapper
::
instance
().
initialize
(
FLAGS_logger_path
,
FLAGS_logger_file
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Failed initialize logger, conf:"
<<
FLAGS_logger_path
<<
"/"
<<
FLAGS_logger_file
;
return
-
1
;
}
// Login to get `CredentialGenerator' (see baas-lib-c/baas.h for more
// information) and then pass it to `GianoAuthenticator'.
std
::
unique_ptr
<
brpc
::
policy
::
GianoAuthenticator
>
auth
;
if
(
FLAGS_auth
)
{
if
(
baas
::
BAAS_Init
()
!=
0
)
{
LOG
(
ERROR
)
<<
"Fail to init BAAS"
;
return
-
1
;
}
baas
::
CredentialGenerator
gen
=
baas
::
ClientUtility
::
Login
(
FLAGS_auth_group
);
auth
.
reset
(
new
brpc
::
policy
::
GianoAuthenticator
(
&
gen
,
NULL
));
}
google
::
InitGoogleLogging
(
strdup
(
argv
[
0
]));
// A Channel represents a communication line to a Server. Notice that
// Channel is thread-safe and can be shared by all threads in your program.
...
...
@@ -399,7 +379,6 @@ int main(int argc, char* argv[]) {
brpc
::
ChannelOptions
options
;
options
.
protocol
=
FLAGS_protocol
;
options
.
connection_type
=
FLAGS_connection_type
;
options
.
auth
=
auth
.
get
();
options
.
timeout_ms
=
FLAGS_timeout_ms
/*milliseconds*/
;
options
.
max_retry
=
FLAGS_max_retry
;
if
(
channel
.
Init
(
FLAGS_server
.
c_str
(),
FLAGS_load_balancer
.
c_str
(),
&
options
)
!=
0
)
{
...
...
@@ -441,6 +420,8 @@ int main(int argc, char* argv[]) {
}
LOG
(
INFO
)
<<
"Pdserving Client is going to quit"
;
google
::
ShutdownGoogleLogging
();
return
0
;
}
predictor/src/pdserving.cpp
浏览文件 @
cc1c24d7
#include <iostream>
#include <fstream>
#include <bthread
_
unstable.h> // bthread_set_worker_startfn
#include <bthread
/
unstable.h> // bthread_set_worker_startfn
#include "common/inner_common.h"
#include "framework/workflow.h"
#include "framework/service.h"
#include "framework/manager.h"
#include "framework/server.h"
#include "
framework/logger
.h"
#include "
butil/logging
.h"
#include "framework/resource.h"
#include "common/constant.h"
using
baidu
::
paddle_serving
::
predictor
::
ServerManager
;
using
baidu
::
paddle_serving
::
predictor
::
WorkflowManager
;
using
baidu
::
paddle_serving
::
predictor
::
LoggerWrapper
;
using
baidu
::
paddle_serving
::
predictor
::
InferServiceManager
;
using
baidu
::
paddle_serving
::
predictor
::
Resource
;
using
baidu
::
paddle_serving
::
predictor
::
FLAGS_workflow_path
;
...
...
@@ -40,7 +39,7 @@ void print_revision(std::ostream& os, void*) {
static
bvar
::
PassiveStatus
<
std
::
string
>
s_predictor_revision
(
"predictor_revision"
,
print_revision
,
NULL
);
DEFINE_bool
(
v
,
false
,
"print version, bool"
);
DEFINE_bool
(
V
,
false
,
"print version, bool"
);
DEFINE_bool
(
g
,
false
,
"user defined gflag path"
);
DECLARE_string
(
flagfile
);
...
...
@@ -72,7 +71,7 @@ int main(int argc, char** argv) {
#endif
google
::
ParseCommandLineFlags
(
&
argc
,
&
argv
,
true
);
if
(
FLAGS_
v
)
{
if
(
FLAGS_
V
)
{
print_revision
(
std
::
cout
,
NULL
);
std
::
cout
<<
std
::
flush
;
return
0
;
...
...
@@ -87,12 +86,7 @@ int main(int argc, char** argv) {
g_change_server_port
();
// initialize logger instance
if
(
LoggerWrapper
::
instance
().
initialize
(
FLAGS_logger_path
,
FLAGS_logger_file
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Failed initialize logger, conf:"
<<
FLAGS_logger_path
<<
"/"
<<
FLAGS_logger_file
;
return
-
1
;
}
google
::
InitGoogleLogging
(
strdup
(
argv
[
0
]));
LOG
(
INFO
)
<<
"Succ initialize logger"
;
...
...
@@ -149,10 +143,7 @@ int main(int argc, char** argv) {
LOG
(
ERROR
)
<<
"Failed finalize resource manager"
;
}
if
(
LoggerWrapper
::
instance
().
finalize
()
!=
0
)
{
LOG
(
ERROR
)
<<
"Failed finalize logger wrapper"
;
}
google
::
ShutdownGoogleLogging
();
LOG
(
INFO
)
<<
"Paddle Inference Server exit successfully!"
;
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录