Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
a27774f2
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看板
提交
a27774f2
编写于
8月 19, 2020
作者:
T
TeslaZhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sync from compiling code in code platform
上级
6c2a607b
变更
28
显示空白变更内容
内联
并排
Showing
28 changed file
with
308 addition
and
222 deletion
+308
-222
core/configure/proto/server_configure.proto
core/configure/proto/server_configure.proto
+2
-0
core/cube/cube-api/include/meta.h
core/cube/cube-api/include/meta.h
+2
-1
core/general-client/src/general_model.cpp
core/general-client/src/general_model.cpp
+2
-0
core/general-server/op/general_copy_op.h
core/general-server/op/general_copy_op.h
+2
-10
core/general-server/op/general_dist_kv_infer_op.h
core/general-server/op/general_dist_kv_infer_op.h
+1
-9
core/general-server/op/general_dist_kv_quant_infer_op.h
core/general-server/op/general_dist_kv_quant_infer_op.h
+1
-9
core/general-server/op/general_infer_helper.h
core/general-server/op/general_infer_helper.h
+1
-9
core/general-server/op/general_infer_op.cpp
core/general-server/op/general_infer_op.cpp
+2
-2
core/general-server/op/general_infer_op.h
core/general-server/op/general_infer_op.h
+1
-9
core/general-server/op/general_reader_op.cpp
core/general-server/op/general_reader_op.cpp
+4
-7
core/general-server/op/general_reader_op.h
core/general-server/op/general_reader_op.h
+2
-10
core/general-server/op/general_response_op.h
core/general-server/op/general_response_op.h
+1
-9
core/general-server/op/general_text_reader_op.h
core/general-server/op/general_text_reader_op.h
+2
-10
core/general-server/op/general_text_response_op.h
core/general-server/op/general_text_response_op.h
+1
-9
core/predictor/common/inner_common.h
core/predictor/common/inner_common.h
+1
-1
core/predictor/framework/factory.h
core/predictor/framework/factory.h
+41
-25
core/predictor/framework/infer.h
core/predictor/framework/infer.h
+7
-0
core/predictor/framework/op_repository.h
core/predictor/framework/op_repository.h
+4
-1
core/predictor/framework/resource.cpp
core/predictor/framework/resource.cpp
+39
-0
core/predictor/framework/service_manager.h
core/predictor/framework/service_manager.h
+33
-23
core/predictor/src/pdserving.cpp
core/predictor/src/pdserving.cpp
+1
-2
core/sdk-cpp/include/abtest.h
core/sdk-cpp/include/abtest.h
+5
-6
core/sdk-cpp/include/factory.h
core/sdk-cpp/include/factory.h
+89
-67
paddle_inference/inferencer-fluid-cpu/include/fluid_cpu_engine.h
...inference/inferencer-fluid-cpu/include/fluid_cpu_engine.h
+1
-0
python/paddle_serving_server/__init__.py
python/paddle_serving_server/__init__.py
+17
-2
python/paddle_serving_server/serve.py
python/paddle_serving_server/serve.py
+14
-0
python/paddle_serving_server_gpu/__init__.py
python/paddle_serving_server_gpu/__init__.py
+26
-0
python/paddle_serving_server_gpu/serve.py
python/paddle_serving_server_gpu/serve.py
+6
-1
未找到文件。
core/configure/proto/server_configure.proto
浏览文件 @
a27774f2
...
@@ -58,6 +58,8 @@ message ResourceConf {
...
@@ -58,6 +58,8 @@ message ResourceConf {
optional
string
cube_config_path
=
5
;
optional
string
cube_config_path
=
5
;
optional
string
cube_config_file
=
6
;
optional
string
cube_config_file
=
6
;
optional
int32
cube_quant_bits
=
7
;
// set 0 if no quant.
optional
int32
cube_quant_bits
=
7
;
// set 0 if no quant.
optional
string
auth_product_name
=
8
;
optional
string
auth_container_id
=
9
;
};
};
// DAG node depency info
// DAG node depency info
...
...
core/cube/cube-api/include/meta.h
浏览文件 @
a27774f2
...
@@ -22,7 +22,8 @@
...
@@ -22,7 +22,8 @@
#ifdef BCLOUD
#ifdef BCLOUD
#include "baidu/rpc/channel.h"
#include "baidu/rpc/channel.h"
#include "baidu/rpc/parallel_channel.h"
#include "baidu/rpc/parallel_channel.h"
#include "rapidjson/document.h"
#include "rapidjson_1.0/document.h"
#include "rapidjson_1.0/rapidjson.h"
#else
#else
#include "brpc/channel.h"
#include "brpc/channel.h"
#include "brpc/parallel_channel.h"
#include "brpc/parallel_channel.h"
...
...
core/general-client/src/general_model.cpp
浏览文件 @
a27774f2
...
@@ -39,7 +39,9 @@ using configure::GeneralModelConfig;
...
@@ -39,7 +39,9 @@ using configure::GeneralModelConfig;
void
PredictorClient
::
init_gflags
(
std
::
vector
<
std
::
string
>
argv
)
{
void
PredictorClient
::
init_gflags
(
std
::
vector
<
std
::
string
>
argv
)
{
std
::
call_once
(
gflags_init_flag
,
[
&
]()
{
std
::
call_once
(
gflags_init_flag
,
[
&
]()
{
#ifndef BCLOUD
FLAGS_logtostderr
=
true
;
FLAGS_logtostderr
=
true
;
#endif
argv
.
insert
(
argv
.
begin
(),
"dummy"
);
argv
.
insert
(
argv
.
begin
(),
"dummy"
);
int
argc
=
argv
.
size
();
int
argc
=
argv
.
size
();
char
**
arr
=
new
char
*
[
argv
.
size
()];
char
**
arr
=
new
char
*
[
argv
.
size
()];
...
...
core/general-server/op/general_copy_op.h
浏览文件 @
a27774f2
...
@@ -13,20 +13,12 @@
...
@@ -13,20 +13,12 @@
// limitations under the License.
// limitations under the License.
#pragma once
#pragma once
#include <vector>
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#endif
#include <string>
#include <string>
#include <vector>
#include "core/general-server/general_model_service.pb.h"
#include "core/general-server/general_model_service.pb.h"
#include "core/general-server/op/general_infer_helper.h"
#include "core/general-server/op/general_infer_helper.h"
#include "core/predictor/framework/resource.h"
#include "core/predictor/framework/resource.h"
#include "paddle_inference_api.h" // NOLINT
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
...
...
core/general-server/op/general_dist_kv_infer_op.h
浏览文件 @
a27774f2
...
@@ -15,17 +15,9 @@
...
@@ -15,17 +15,9 @@
#pragma once
#pragma once
#include <string>
#include <string>
#include <vector>
#include <vector>
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#endif
#include "core/general-server/general_model_service.pb.h"
#include "core/general-server/general_model_service.pb.h"
#include "core/general-server/op/general_infer_helper.h"
#include "core/general-server/op/general_infer_helper.h"
#include "paddle_inference_api.h" // NOLINT
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
...
...
core/general-server/op/general_dist_kv_quant_infer_op.h
浏览文件 @
a27774f2
...
@@ -15,17 +15,9 @@
...
@@ -15,17 +15,9 @@
#pragma once
#pragma once
#include <string>
#include <string>
#include <vector>
#include <vector>
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#endif
#include "core/general-server/general_model_service.pb.h"
#include "core/general-server/general_model_service.pb.h"
#include "core/general-server/op/general_infer_helper.h"
#include "core/general-server/op/general_infer_helper.h"
#include "paddle_inference_api.h" // NOLINT
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
...
...
core/general-server/op/general_infer_helper.h
浏览文件 @
a27774f2
...
@@ -15,17 +15,9 @@
...
@@ -15,17 +15,9 @@
#pragma once
#pragma once
#include <string.h>
#include <string.h>
#include <string>
#include <vector>
#include <vector>
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#include "paddle_inference_api.h" // NOLINT
#endif
#include <string>
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
...
...
core/general-server/op/general_infer_op.cpp
浏览文件 @
a27774f2
...
@@ -57,10 +57,10 @@ int GeneralInferOp::inference() {
...
@@ -57,10 +57,10 @@ int GeneralInferOp::inference() {
const
TensorVector
*
in
=
&
input_blob
->
tensor_vector
;
const
TensorVector
*
in
=
&
input_blob
->
tensor_vector
;
TensorVector
*
out
=
&
output_blob
->
tensor_vector
;
TensorVector
*
out
=
&
output_blob
->
tensor_vector
;
int
batch_size
=
input_blob
->
GetBatchSize
()
;
int
batch_size
=
input_blob
->
_batch_size
;
VLOG
(
2
)
<<
"input batch size: "
<<
batch_size
;
VLOG
(
2
)
<<
"input batch size: "
<<
batch_size
;
output_blob
->
SetBatchSize
(
batch_size
)
;
output_blob
->
_batch_size
=
batch_size
;
VLOG
(
2
)
<<
"infer batch size: "
<<
batch_size
;
VLOG
(
2
)
<<
"infer batch size: "
<<
batch_size
;
...
...
core/general-server/op/general_infer_op.h
浏览文件 @
a27774f2
...
@@ -15,17 +15,9 @@
...
@@ -15,17 +15,9 @@
#pragma once
#pragma once
#include <string>
#include <string>
#include <vector>
#include <vector>
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#endif
#include "core/general-server/general_model_service.pb.h"
#include "core/general-server/general_model_service.pb.h"
#include "core/general-server/op/general_infer_helper.h"
#include "core/general-server/op/general_infer_helper.h"
#include "paddle_inference_api.h" // NOLINT
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
...
...
core/general-server/op/general_reader_op.cpp
浏览文件 @
a27774f2
...
@@ -72,7 +72,9 @@ int conf_check(const Request *req,
...
@@ -72,7 +72,9 @@ int conf_check(const Request *req,
int
GeneralReaderOp
::
inference
()
{
int
GeneralReaderOp
::
inference
()
{
// reade request from client
// reade request from client
const
Request
*
req
=
dynamic_cast
<
const
Request
*>
(
get_request_message
());
const
Request
*
req
=
dynamic_cast
<
const
Request
*>
(
get_request_message
());
VLOG
(
2
)
<<
"start to call load general model_conf op"
;
baidu
::
paddle_serving
::
predictor
::
Resource
&
resource
=
baidu
::
paddle_serving
::
predictor
::
Resource
::
instance
();
int
batch_size
=
req
->
insts_size
();
int
batch_size
=
req
->
insts_size
();
int
input_var_num
=
0
;
int
input_var_num
=
0
;
std
::
vector
<
int64_t
>
elem_type
;
std
::
vector
<
int64_t
>
elem_type
;
...
@@ -82,8 +84,6 @@ int GeneralReaderOp::inference() {
...
@@ -82,8 +84,6 @@ int GeneralReaderOp::inference() {
GeneralBlob
*
res
=
mutable_data
<
GeneralBlob
>
();
GeneralBlob
*
res
=
mutable_data
<
GeneralBlob
>
();
TensorVector
*
out
=
&
res
->
tensor_vector
;
TensorVector
*
out
=
&
res
->
tensor_vector
;
res
->
SetBatchSize
(
batch_size
);
if
(
!
res
)
{
if
(
!
res
)
{
LOG
(
ERROR
)
<<
"Failed get op tls reader object output"
;
LOG
(
ERROR
)
<<
"Failed get op tls reader object output"
;
}
}
...
@@ -93,10 +93,6 @@ int GeneralReaderOp::inference() {
...
@@ -93,10 +93,6 @@ int GeneralReaderOp::inference() {
int
var_num
=
req
->
insts
(
0
).
tensor_array_size
();
int
var_num
=
req
->
insts
(
0
).
tensor_array_size
();
VLOG
(
2
)
<<
"var num: "
<<
var_num
;
VLOG
(
2
)
<<
"var num: "
<<
var_num
;
VLOG
(
2
)
<<
"start to call load general model_conf op"
;
baidu
::
paddle_serving
::
predictor
::
Resource
&
resource
=
baidu
::
paddle_serving
::
predictor
::
Resource
::
instance
();
VLOG
(
2
)
<<
"get resource pointer done."
;
VLOG
(
2
)
<<
"get resource pointer done."
;
std
::
shared_ptr
<
PaddleGeneralModelConfig
>
model_config
=
std
::
shared_ptr
<
PaddleGeneralModelConfig
>
model_config
=
resource
.
get_general_model_config
();
resource
.
get_general_model_config
();
...
@@ -257,6 +253,7 @@ int GeneralReaderOp::inference() {
...
@@ -257,6 +253,7 @@ int GeneralReaderOp::inference() {
timeline
.
Pause
();
timeline
.
Pause
();
int64_t
end
=
timeline
.
TimeStampUS
();
int64_t
end
=
timeline
.
TimeStampUS
();
res
->
p_size
=
0
;
res
->
p_size
=
0
;
res
->
_batch_size
=
batch_size
;
AddBlobInfo
(
res
,
start
);
AddBlobInfo
(
res
,
start
);
AddBlobInfo
(
res
,
end
);
AddBlobInfo
(
res
,
end
);
...
...
core/general-server/op/general_reader_op.h
浏览文件 @
a27774f2
...
@@ -13,21 +13,13 @@
...
@@ -13,21 +13,13 @@
// limitations under the License.
// limitations under the License.
#pragma once
#pragma once
#include <vector>
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#endif
#include <string>
#include <string>
#include <vector>
#include "core/general-server/general_model_service.pb.h"
#include "core/general-server/general_model_service.pb.h"
#include "core/general-server/load_general_model_service.pb.h"
#include "core/general-server/load_general_model_service.pb.h"
#include "core/general-server/op/general_infer_helper.h"
#include "core/general-server/op/general_infer_helper.h"
#include "core/predictor/framework/resource.h"
#include "core/predictor/framework/resource.h"
#include "paddle_inference_api.h" // NOLINT
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
...
...
core/general-server/op/general_response_op.h
浏览文件 @
a27774f2
...
@@ -15,16 +15,8 @@
...
@@ -15,16 +15,8 @@
#pragma once
#pragma once
#include <string>
#include <string>
#include <vector>
#include <vector>
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#endif
#include "core/general-server/general_model_service.pb.h"
#include "core/general-server/general_model_service.pb.h"
#include "paddle_inference_api.h" // NOLINT
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
...
...
core/general-server/op/general_text_reader_op.h
浏览文件 @
a27774f2
...
@@ -13,21 +13,13 @@
...
@@ -13,21 +13,13 @@
// limitations under the License.
// limitations under the License.
#pragma once
#pragma once
#include <vector>
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#endif
#include <string>
#include <string>
#include <vector>
#include "core/general-server/general_model_service.pb.h"
#include "core/general-server/general_model_service.pb.h"
#include "core/general-server/load_general_model_service.pb.h"
#include "core/general-server/load_general_model_service.pb.h"
#include "core/general-server/op/general_infer_helper.h"
#include "core/general-server/op/general_infer_helper.h"
#include "core/predictor/framework/resource.h"
#include "core/predictor/framework/resource.h"
#include "paddle_inference_api.h" // NOLINT
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
...
...
core/general-server/op/general_text_response_op.h
浏览文件 @
a27774f2
...
@@ -15,17 +15,9 @@
...
@@ -15,17 +15,9 @@
#pragma once
#pragma once
#include <string>
#include <string>
#include <vector>
#include <vector>
#ifdef BCLOUD
#ifdef WITH_GPU
#include "paddle/paddle_inference_api.h"
#else
#include "paddle/fluid/inference/api/paddle_inference_api.h"
#endif
#else
#include "paddle_inference_api.h" // NOLINT
#endif
#include "core/general-server/general_model_service.pb.h"
#include "core/general-server/general_model_service.pb.h"
#include "core/general-server/op/general_infer_helper.h"
#include "core/general-server/op/general_infer_helper.h"
#include "paddle_inference_api.h" // NOLINT
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
...
...
core/predictor/common/inner_common.h
浏览文件 @
a27774f2
...
@@ -50,7 +50,7 @@
...
@@ -50,7 +50,7 @@
#include "butil/time.h"
#include "butil/time.h"
#endif
#endif
#
include "glog/raw_logging.h"
#
define ERROR_STRING_LEN 10240
#include "core/configure/general_model_config.pb.h"
#include "core/configure/general_model_config.pb.h"
#include "core/configure/include/configure_parser.h"
#include "core/configure/include/configure_parser.h"
...
...
core/predictor/framework/factory.h
浏览文件 @
a27774f2
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
#include <string>
#include <string>
#include <utility>
#include <utility>
#include "core/predictor/common/inner_common.h"
#include "core/predictor/common/inner_common.h"
#include "glog/raw_logging.h"
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
namespace
predictor
{
namespace
predictor
{
...
@@ -25,10 +25,13 @@ namespace predictor {
...
@@ -25,10 +25,13 @@ namespace predictor {
//////////////// DECLARE INTERFACE ////////////////
//////////////// DECLARE INTERFACE ////////////////
#define DECLARE_FACTORY_OBJECT(D, B) \
#define DECLARE_FACTORY_OBJECT(D, B) \
static int regist(const std::string& tag) { \
static int regist(const std::string& tag) { \
FactoryDerive<D, B>* factory = new (std::nothrow) FactoryDerive<D, B>();
\
FactoryDerive<D, B>* factory = new (std::nothrow) FactoryDerive<D, B>();\
if (factory == NULL || \
if (factory == NULL || \
FactoryPool<B>::instance().register_factory(tag, factory) != 0) { \
FactoryPool<B>::instance().register_factory(tag, factory) != 0) { \
RAW_LOG_FATAL("Failed regist factory: %s in macro!", #D); \
char err_str[ERROR_STRING_LEN]; \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Failed regist factory: %s in macro!", #D); \
RAW_LOG(FATAL, err_str); \
return -1; \
return -1; \
} \
} \
return 0; \
return 0; \
...
@@ -54,7 +57,10 @@ namespace predictor {
...
@@ -54,7 +57,10 @@ namespace predictor {
if (factory == NULL || \
if (factory == NULL || \
::baidu::paddle_serving::predictor::FactoryPool<B>::instance() \
::baidu::paddle_serving::predictor::FactoryPool<B>::instance() \
.register_factory(#D, factory) != 0) { \
.register_factory(#D, factory) != 0) { \
RAW_LOG_FATAL("Failed regist factory: %s->%s in macro!", #D, #B); \
char err_str[ERROR_STRING_LEN]; \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->%s in macro!", #D, #B); \
RAW_LOG(FATAL, err_str); \
return; \
return; \
} \
} \
return; \
return; \
...
@@ -66,15 +72,18 @@ namespace predictor {
...
@@ -66,15 +72,18 @@ namespace predictor {
::baidu::paddle_serving::predictor::FactoryDerive<D, B>* factory = new ( \
::baidu::paddle_serving::predictor::FactoryDerive<D, B>* factory = new ( \
::std::nothrow)::baidu::paddle_serving::predictor::FactoryDerive<D, \
::std::nothrow)::baidu::paddle_serving::predictor::FactoryDerive<D, \
B>(); \
B>(); \
char err_str[ERROR_STRING_LEN]; \
if (factory == NULL || \
if (factory == NULL || \
::baidu::paddle_serving::predictor::FactoryPool<B>::instance() \
::baidu::paddle_serving::predictor::FactoryPool<B>::instance() \
.register_factory(N, factory) != 0) { \
.register_factory(N, factory) != 0) { \
RAW_LOG_FATAL(
\
snprintf(err_str, ERROR_STRING_LEN - 1,
\
"Failed regist factory: %s->%s, tag: %s in macro!", #D, #B, N); \
"Failed regist factory: %s->%s, tag: %s in macro!", #D, #B, N); \
RAW_LOG(FATAL, err_str); \
return; \
return; \
} \
} \
RAW_LOG_WARNING(
\
snprintf(err_str, ERROR_STRING_LEN - 1,
\
"Succ regist factory: %s->%s, tag: %s in macro!", #D, #B, N); \
"Succ regist factory: %s->%s, tag: %s in macro!", #D, #B, N); \
RAW_LOG(WARNING, err_str); \
return; \
return; \
}
}
...
@@ -102,24 +111,29 @@ class FactoryPool {
...
@@ -102,24 +111,29 @@ class FactoryPool {
}
}
int
register_factory
(
const
std
::
string
&
tag
,
FactoryBase
<
B
>*
factory
)
{
int
register_factory
(
const
std
::
string
&
tag
,
FactoryBase
<
B
>*
factory
)
{
char
err_str
[
ERROR_STRING_LEN
];
typename
std
::
map
<
std
::
string
,
FactoryBase
<
B
>*>::
iterator
it
=
typename
std
::
map
<
std
::
string
,
FactoryBase
<
B
>*>::
iterator
it
=
_pool
.
find
(
tag
);
_pool
.
find
(
tag
);
if
(
it
!=
_pool
.
end
())
{
if
(
it
!=
_pool
.
end
())
{
RAW_LOG_FATAL
(
"Insert duplicate with tag: %s"
,
tag
.
c_str
());
snprintf
(
err_str
,
ERROR_STRING_LEN
-
1
,
"Insert duplicate with tag: %s"
,
tag
.
c_str
());
RAW_LOG
(
FATAL
,
err_str
);
return
-
1
;
return
-
1
;
}
}
std
::
pair
<
typename
std
::
map
<
std
::
string
,
FactoryBase
<
B
>*>::
iterator
,
bool
>
std
::
pair
<
typename
std
::
map
<
std
::
string
,
FactoryBase
<
B
>*>::
iterator
,
bool
>
r
=
_pool
.
insert
(
std
::
make_pair
(
tag
,
factory
));
r
=
_pool
.
insert
(
std
::
make_pair
(
tag
,
factory
));
if
(
!
r
.
second
)
{
if
(
!
r
.
second
)
{
RAW_LOG_FATAL
(
"Failed insert new factory with: %s"
,
tag
.
c_str
());
snprintf
(
err_str
,
ERROR_STRING_LEN
-
1
,
"Failed insert new factory with: %s"
,
tag
.
c_str
());
RAW_LOG
(
FATAL
,
err_str
);
return
-
1
;
return
-
1
;
}
}
RAW_LOG_INFO
(
"Succ insert one factory, tag: %s, base type %s"
,
snprintf
(
err_str
,
ERROR_STRING_LEN
-
1
,
tag
.
c_str
(),
"Succ insert one factory, tag: %s, base type %s"
,
tag
.
c_str
(),
typeid
(
B
).
name
());
typeid
(
B
).
name
());
RAW_LOG
(
INFO
,
err_str
);
return
0
;
return
0
;
}
}
...
@@ -127,9 +141,11 @@ class FactoryPool {
...
@@ -127,9 +141,11 @@ class FactoryPool {
typename
std
::
map
<
std
::
string
,
FactoryBase
<
B
>*>::
iterator
it
=
typename
std
::
map
<
std
::
string
,
FactoryBase
<
B
>*>::
iterator
it
=
_pool
.
find
(
tag
);
_pool
.
find
(
tag
);
if
(
it
==
_pool
.
end
()
||
it
->
second
==
NULL
)
{
if
(
it
==
_pool
.
end
()
||
it
->
second
==
NULL
)
{
RAW_LOG_FATAL
(
"Not found factory pool, tag: %s, pool size %u"
,
char
err_str
[
ERROR_STRING_LEN
];
tag
.
c_str
(),
snprintf
(
err_str
,
ERROR_STRING_LEN
-
1
,
"Not found factory pool, tag: %s, pool size %u"
,
tag
.
c_str
(),
_pool
.
size
());
_pool
.
size
());
RAW_LOG
(
FATAL
,
err_str
);
return
NULL
;
return
NULL
;
}
}
...
...
core/predictor/framework/infer.h
浏览文件 @
a27774f2
...
@@ -603,6 +603,7 @@ class VersionedInferEngine : public InferEngine {
...
@@ -603,6 +603,7 @@ class VersionedInferEngine : public InferEngine {
LOG
(
ERROR
)
<<
"Failed generate engine with type:"
<<
engine_type
;
LOG
(
ERROR
)
<<
"Failed generate engine with type:"
<<
engine_type
;
return
-
1
;
return
-
1
;
}
}
#ifndef BCLOUD
VLOG
(
2
)
<<
"FLAGS_logtostderr "
<<
FLAGS_logtostderr
;
VLOG
(
2
)
<<
"FLAGS_logtostderr "
<<
FLAGS_logtostderr
;
int
tmp
=
FLAGS_logtostderr
;
int
tmp
=
FLAGS_logtostderr
;
if
(
engine
->
proc_initialize
(
conf
,
version
)
!=
0
)
{
if
(
engine
->
proc_initialize
(
conf
,
version
)
!=
0
)
{
...
@@ -611,6 +612,12 @@ class VersionedInferEngine : public InferEngine {
...
@@ -611,6 +612,12 @@ class VersionedInferEngine : public InferEngine {
}
}
VLOG
(
2
)
<<
"FLAGS_logtostderr "
<<
FLAGS_logtostderr
;
VLOG
(
2
)
<<
"FLAGS_logtostderr "
<<
FLAGS_logtostderr
;
FLAGS_logtostderr
=
tmp
;
FLAGS_logtostderr
=
tmp
;
#else
if
(
engine
->
proc_initialize
(
conf
,
version
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Failed initialize engine, type:"
<<
engine_type
;
return
-
1
;
}
#endif
auto
r
=
_versions
.
insert
(
std
::
make_pair
(
engine
->
version
(),
engine
));
auto
r
=
_versions
.
insert
(
std
::
make_pair
(
engine
->
version
(),
engine
));
if
(
!
r
.
second
)
{
if
(
!
r
.
second
)
{
LOG
(
ERROR
)
<<
"Failed insert item: "
<<
engine
->
version
()
LOG
(
ERROR
)
<<
"Failed insert item: "
<<
engine
->
version
()
...
...
core/predictor/framework/op_repository.h
浏览文件 @
a27774f2
...
@@ -62,7 +62,10 @@ class OpRepository {
...
@@ -62,7 +62,10 @@ class OpRepository {
template
<
typename
OP_TYPE
>
template
<
typename
OP_TYPE
>
void
regist_op
(
std
::
string
op_type
)
{
void
regist_op
(
std
::
string
op_type
)
{
_repository
[
op_type
]
=
&
OpFactory
<
OP_TYPE
>::
instance
();
_repository
[
op_type
]
=
&
OpFactory
<
OP_TYPE
>::
instance
();
RAW_LOG_INFO
(
"Succ regist op: %s"
,
op_type
.
c_str
());
char
err_str
[
ERROR_STRING_LEN
];
snprintf
(
err_str
,
ERROR_STRING_LEN
-
1
,
"Succ regist op: %s"
,
op_type
.
c_str
());
RAW_LOG
(
INFO
,
err_str
);
}
}
Op
*
get_op
(
std
::
string
op_type
);
Op
*
get_op
(
std
::
string
op_type
);
...
...
core/predictor/framework/resource.cpp
浏览文件 @
a27774f2
...
@@ -17,6 +17,9 @@
...
@@ -17,6 +17,9 @@
#include <string>
#include <string>
#include "core/predictor/common/inner_common.h"
#include "core/predictor/common/inner_common.h"
#include "core/predictor/framework/kv_manager.h"
#include "core/predictor/framework/kv_manager.h"
#ifdef BCLOUD
#include "aipe_sec_client.h" // NOLINT
#endif
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
namespace
predictor
{
namespace
predictor
{
...
@@ -109,6 +112,42 @@ int Resource::initialize(const std::string& path, const std::string& file) {
...
@@ -109,6 +112,42 @@ int Resource::initialize(const std::string& path, const std::string& file) {
}
}
LOG
(
WARNING
)
<<
"Successfully proc initialized mempool wrapper"
;
LOG
(
WARNING
)
<<
"Successfully proc initialized mempool wrapper"
;
#ifdef WITH_AUTH
std
::
string
product_name_str
=
resource_conf
.
auth_product_name
();
std
::
string
container_id_str
=
resource_conf
.
auth_container_id
();
char
*
product_name
=
new
char
[
product_name_str
.
size
()
+
1
];
snprintf
(
product_name
,
product_name_str
.
size
()
+
1
,
"%s"
,
product_name_str
.
c_str
());
char
*
container_id
=
new
char
[
container_id_str
.
size
()
+
1
];
snprintf
(
container_id
,
container_id_str
.
size
()
+
1
,
"%s"
,
container_id_str
.
c_str
());
aipe_auth_request
request
;
request
.
product_name
=
product_name
;
request
.
container_id
=
container_id
;
request
.
request_ts
=
(
int64_t
)
time
(
NULL
);
LOG
(
INFO
)
<<
"
\n
Easypack info"
<<
"
\n
product name: "
<<
request
.
product_name
<<
"
\n
container_id: "
<<
request
.
container_id
<<
"
\n
request time stamp: "
<<
request
.
request_ts
;
aipe_auth_response
response
;
response
=
check_auth
(
request
);
if
(
response
.
result
==
0
)
{
LOG
(
INFO
)
<<
"Authentication succeed."
;
}
else
{
LOG
(
ERROR
)
<<
"Authentication failed. Error code: "
<<
response
.
result
;
return
-
1
;
}
#endif
if
(
FLAGS_enable_model_toolkit
)
{
if
(
FLAGS_enable_model_toolkit
)
{
int
err
=
0
;
int
err
=
0
;
std
::
string
model_toolkit_path
=
resource_conf
.
model_toolkit_path
();
std
::
string
model_toolkit_path
=
resource_conf
.
model_toolkit_path
();
...
...
core/predictor/framework/service_manager.h
浏览文件 @
a27774f2
...
@@ -23,17 +23,20 @@ namespace predictor {
...
@@ -23,17 +23,20 @@ namespace predictor {
#define REGIST_FORMAT_SERVICE(svr_name, svr) \
#define REGIST_FORMAT_SERVICE(svr_name, svr) \
do { \
do { \
char err_str[ERROR_STRING_LEN]; \
int ret = \
int ret = \
::baidu::paddle_serving::predictor::FormatServiceManager::instance() \
::baidu::paddle_serving::predictor::FormatServiceManager::instance() \
.regist_service(svr_name, svr); \
.regist_service(svr_name, svr); \
if (ret != 0) { \
if (ret != 0) { \
RAW_LOG_ERROR("Failed regist service[%s][%s]",
\
snprintf(err_str, ERROR_STRING_LEN - 1, "Failed regist service[%s][%s]",
\
svr_name.c_str(), \
svr_name.c_str(), \
typeid(svr).name()); \
typeid(svr).name()); \
RAW_LOG(ERROR, err_str); \
} else { \
} else { \
RAW_LOG_INFO("Success regist service[%s][%s]",
\
snprintf(err_str, ERROR_STRING_LEN - 1, "Success regist service[%s][%s]",
\
svr_name.c_str(), \
svr_name.c_str(), \
typeid(svr).name()); \
typeid(svr).name()); \
RAW_LOG(INFO, err_str); \
} \
} \
} while (0)
} while (0)
...
@@ -42,31 +45,38 @@ class FormatServiceManager {
...
@@ -42,31 +45,38 @@ class FormatServiceManager {
typedef
google
::
protobuf
::
Service
Service
;
typedef
google
::
protobuf
::
Service
Service
;
int
regist_service
(
const
std
::
string
&
svr_name
,
Service
*
svr
)
{
int
regist_service
(
const
std
::
string
&
svr_name
,
Service
*
svr
)
{
char
err_str
[
ERROR_STRING_LEN
];
if
(
_service_map
.
find
(
svr_name
)
!=
_service_map
.
end
())
{
if
(
_service_map
.
find
(
svr_name
)
!=
_service_map
.
end
())
{
RAW_LOG_ERROR
(
"Service[%s][%s] already exist!"
,
snprintf
(
err_str
,
ERROR_STRING_LEN
-
1
,
"Service[%s][%s] already exist!"
,
svr_name
.
c_str
(),
svr_name
.
c_str
(),
typeid
(
svr
).
name
());
typeid
(
svr
).
name
());
RAW_LOG
(
ERROR
,
err_str
);
return
-
1
;
return
-
1
;
}
}
std
::
pair
<
boost
::
unordered_map
<
std
::
string
,
Service
*>::
iterator
,
bool
>
ret
;
std
::
pair
<
boost
::
unordered_map
<
std
::
string
,
Service
*>::
iterator
,
bool
>
ret
;
ret
=
_service_map
.
insert
(
std
::
make_pair
(
svr_name
,
svr
));
ret
=
_service_map
.
insert
(
std
::
make_pair
(
svr_name
,
svr
));
if
(
ret
.
second
==
false
)
{
if
(
ret
.
second
==
false
)
{
RAW_LOG_ERROR
(
"Service[%s][%s] insert failed!"
,
snprintf
(
err_str
,
ERROR_STRING_LEN
-
1
,
"Service[%s][%s] insert failed!"
,
svr_name
.
c_str
(),
svr_name
.
c_str
(),
typeid
(
svr
).
name
());
typeid
(
svr
).
name
());
RAW_LOG
(
ERROR
,
err_str
);
return
-
1
;
return
-
1
;
}
}
RAW_LOG_INFO
(
"Service[%s] insert successfully!"
,
svr_name
.
c_str
());
snprintf
(
err_str
,
ERROR_STRING_LEN
-
1
,
"Service[%s] insert successfully!"
,
svr_name
.
c_str
());
RAW_LOG
(
INFO
,
err_str
);
return
0
;
return
0
;
}
}
Service
*
get_service
(
const
std
::
string
&
svr_name
)
{
Service
*
get_service
(
const
std
::
string
&
svr_name
)
{
char
err_str
[
ERROR_STRING_LEN
];
boost
::
unordered_map
<
std
::
string
,
Service
*>::
iterator
res
;
boost
::
unordered_map
<
std
::
string
,
Service
*>::
iterator
res
;
if
((
res
=
_service_map
.
find
(
svr_name
))
==
_service_map
.
end
())
{
if
((
res
=
_service_map
.
find
(
svr_name
))
==
_service_map
.
end
())
{
RAW_LOG_WARNING
(
"Service[%s] not found in service manager!"
,
snprintf
(
err_str
,
ERROR_STRING_LEN
-
1
,
svr_name
.
c_str
());
"Service[%s] not found in service manager!"
,
svr_name
.
c_str
());
RAW_LOG
(
WARNING
,
err_str
);
return
NULL
;
return
NULL
;
}
}
return
(
*
res
).
second
;
return
(
*
res
).
second
;
...
...
core/predictor/src/pdserving.cpp
浏览文件 @
a27774f2
...
@@ -202,8 +202,6 @@ int main(int argc, char** argv) {
...
@@ -202,8 +202,6 @@ int main(int argc, char** argv) {
}
}
VLOG
(
2
)
<<
"Succ call pthread worker start function"
;
VLOG
(
2
)
<<
"Succ call pthread worker start function"
;
#ifndef BCLOUD
if
(
Resource
::
instance
().
general_model_initialize
(
FLAGS_resource_path
,
if
(
Resource
::
instance
().
general_model_initialize
(
FLAGS_resource_path
,
FLAGS_resource_file
)
!=
0
)
{
FLAGS_resource_file
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Failed to initialize general model conf: "
LOG
(
ERROR
)
<<
"Failed to initialize general model conf: "
...
@@ -213,6 +211,7 @@ int main(int argc, char** argv) {
...
@@ -213,6 +211,7 @@ int main(int argc, char** argv) {
VLOG
(
2
)
<<
"Succ initialize general model"
;
VLOG
(
2
)
<<
"Succ initialize general model"
;
#ifndef BCLOUD
// FATAL messages are output to stderr
// FATAL messages are output to stderr
FLAGS_stderrthreshold
=
3
;
FLAGS_stderrthreshold
=
3
;
#endif
#endif
...
...
core/sdk-cpp/include/abtest.h
浏览文件 @
a27774f2
...
@@ -50,9 +50,9 @@ class WeightedRandomRender : public EndpointRouterBase {
...
@@ -50,9 +50,9 @@ class WeightedRandomRender : public EndpointRouterBase {
Factory
<
WeightedRandomRender
,
EndpointRouterBase
>*
factory
=
Factory
<
WeightedRandomRender
,
EndpointRouterBase
>*
factory
=
new
(
std
::
nothrow
)
Factory
<
WeightedRandomRender
,
EndpointRouterBase
>
();
new
(
std
::
nothrow
)
Factory
<
WeightedRandomRender
,
EndpointRouterBase
>
();
if
(
factory
==
NULL
)
{
if
(
factory
==
NULL
)
{
RAW_LOG
_ERROR
(
RAW_LOG
(
ERROR
,
"Failed regist factory: WeightedRandomRender->EndpointRouterBase
in "
"Failed regist factory: WeightedRandomRender->EndpointRouterBase
\
"
macro!"
);
in
macro!"
);
return
-
1
;
return
-
1
;
}
}
...
@@ -62,9 +62,8 @@ class WeightedRandomRender : public EndpointRouterBase {
...
@@ -62,9 +62,8 @@ class WeightedRandomRender : public EndpointRouterBase {
// together.
// together.
if
(
FactoryPool
<
EndpointRouterBase
>::
instance
().
register_factory
(
if
(
FactoryPool
<
EndpointRouterBase
>::
instance
().
register_factory
(
"WeightedRandomRender"
,
factory
)
!=
0
)
{
"WeightedRandomRender"
,
factory
)
!=
0
)
{
RAW_LOG_INFO
(
RAW_LOG
(
INFO
,
"Factory has been registed: \
"Factory has been registed: "
WeightedRandomRender->EndpointRouterBase."
);
"WeightedRandomRender->EndpointRouterBase."
);
}
}
return
0
;
return
0
;
...
...
core/sdk-cpp/include/factory.h
浏览文件 @
a27774f2
...
@@ -18,7 +18,6 @@
...
@@ -18,7 +18,6 @@
#include <utility>
#include <utility>
#include "core/sdk-cpp/include/common.h"
#include "core/sdk-cpp/include/common.h"
#include "core/sdk-cpp/include/stub_impl.h"
#include "core/sdk-cpp/include/stub_impl.h"
#include "glog/raw_logging.h"
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
...
@@ -28,12 +27,17 @@ namespace sdk_cpp {
...
@@ -28,12 +27,17 @@ namespace sdk_cpp {
namespace
brpc
=
baidu
::
rpc
;
namespace
brpc
=
baidu
::
rpc
;
#endif
#endif
#define ERROR_STRING_LEN 10240
#define INLINE_REGIST_OBJECT(D, B, E) \
#define INLINE_REGIST_OBJECT(D, B, E) \
do { \
do { \
Factory<D, B>* factory = new (std::nothrow) Factory<D, B>(); \
Factory<D, B>* factory = new (std::nothrow) Factory<D, B>(); \
if (factory == NULL || \
if (factory == NULL || \
FactoryPool<B>::instance().register_factory(#D, factory) != 0) { \
FactoryPool<B>::instance().register_factory(#D, factory) != 0) {\
RAW_LOG_ERROR("Failed regist factory: %s->%s in macro!", #D, #B); \
char err_str[ERROR_STRING_LEN]; \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->%s in macro!", #D, #B); \
RAW_LOG(ERROR, err_str); \
return E; \
return E; \
} \
} \
} while (0)
} while (0)
...
@@ -43,7 +47,10 @@ namespace brpc = baidu::rpc;
...
@@ -43,7 +47,10 @@ namespace brpc = baidu::rpc;
Factory<D, B>* factory = new (std::nothrow) Factory<D, B>(); \
Factory<D, B>* factory = new (std::nothrow) Factory<D, B>(); \
if (factory == NULL || \
if (factory == NULL || \
FactoryPool<B>::instance().register_factory(tag, factory) != 0) { \
FactoryPool<B>::instance().register_factory(tag, factory) != 0) { \
RAW_LOG_ERROR("Failed regist factory: %s in macro!", #D); \
char err_str[ERROR_STRING_LEN]; \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Failed regist factory: %s in macro!", #D); \
RAW_LOG(ERROR, err_str); \
return -1; \
return -1; \
} \
} \
return 0; \
return 0; \
...
@@ -62,11 +69,14 @@ namespace brpc = baidu::rpc;
...
@@ -62,11 +69,14 @@ namespace brpc = baidu::rpc;
__attribute__((constructor)) static void PDS_STR_CAT(GlobalRegistObject, \
__attribute__((constructor)) static void PDS_STR_CAT(GlobalRegistObject, \
__LINE__)(void) { \
__LINE__)(void) { \
::baidu::paddle_serving::sdk_cpp::Factory<D, B>* factory = \
::baidu::paddle_serving::sdk_cpp::Factory<D, B>* factory = \
new (::std::nothrow)::baidu::paddle_serving::sdk_cpp::Factory<D, B>();
\
new (::std::nothrow)::baidu::paddle_serving::sdk_cpp::Factory<D, B>();
\
if (factory == NULL || \
if (factory == NULL || \
::baidu::paddle_serving::sdk_cpp::FactoryPool<B>::instance() \
::baidu::paddle_serving::sdk_cpp::FactoryPool<B>::instance() \
.register_factory(#D, factory) != 0) { \
.register_factory(#D, factory) != 0) { \
RAW_LOG_ERROR("Failed regist factory: %s->%s in macro!", #D, #B); \
char err_str[ERROR_STRING_LEN]; \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->%s in macro!", #D, #B); \
RAW_LOG(ERROR, err_str); \
return; \
return; \
} \
} \
return; \
return; \
...
@@ -76,12 +86,14 @@ namespace brpc = baidu::rpc;
...
@@ -76,12 +86,14 @@ namespace brpc = baidu::rpc;
__attribute__((constructor)) static void PDS_STR_CAT(GlobalRegistObject, \
__attribute__((constructor)) static void PDS_STR_CAT(GlobalRegistObject, \
__LINE__)(void) { \
__LINE__)(void) { \
::baidu::paddle_serving::sdk_cpp::Factory<D, B>* factory = \
::baidu::paddle_serving::sdk_cpp::Factory<D, B>* factory = \
new (::std::nothrow)::baidu::paddle_serving::sdk_cpp::Factory<D, B>();
\
new (::std::nothrow)::baidu::paddle_serving::sdk_cpp::Factory<D, B>();
\
if (factory == NULL || \
if (factory == NULL || \
::baidu::paddle_serving::sdk_cpp::FactoryPool<B>::instance() \
::baidu::paddle_serving::sdk_cpp::FactoryPool<B>::instance() \
.register_factory(T, factory) != 0) { \
.register_factory(T, factory) != 0) { \
RAW_LOG_ERROR( \
char err_str[ERROR_STRING_LEN]; \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->%s, tag %s in macro!", #D, #B, T); \
"Failed regist factory: %s->%s, tag %s in macro!", #D, #B, T); \
RAW_LOG(ERROR, err_str); \
return; \
return; \
} \
} \
return; \
return; \
...
@@ -108,8 +120,10 @@ namespace brpc = baidu::rpc;
...
@@ -108,8 +120,10 @@ namespace brpc = baidu::rpc;
::baidu::paddle_serving::sdk_cpp::FactoryPool< \
::baidu::paddle_serving::sdk_cpp::FactoryPool< \
::baidu::paddle_serving::sdk_cpp::Stub>::instance() \
::baidu::paddle_serving::sdk_cpp::Stub>::instance() \
.register_factory(T, factory) != 0) { \
.register_factory(T, factory) != 0) { \
RAW_LOG_ERROR( \
char err_str[ERROR_STRING_LEN]; \
snprintf(err_str, ERROR_STRING_LEN - 1, \
"Failed regist factory: %s->Stub, tag: %s in macro!", #D, T); \
"Failed regist factory: %s->Stub, tag: %s in macro!", #D, T); \
RAW_LOG(ERROR, err_str); \
return; \
return; \
} \
} \
return; \
return; \
...
@@ -146,14 +160,20 @@ class FactoryPool {
...
@@ -146,14 +160,20 @@ class FactoryPool {
typename
std
::
map
<
std
::
string
,
FactoryBase
<
B
>*>::
iterator
it
=
typename
std
::
map
<
std
::
string
,
FactoryBase
<
B
>*>::
iterator
it
=
_pool
.
find
(
tag
);
_pool
.
find
(
tag
);
if
(
it
!=
_pool
.
end
())
{
if
(
it
!=
_pool
.
end
())
{
RAW_LOG_ERROR
(
"Insert duplicate with tag: %s"
,
tag
.
c_str
());
char
err_str
[
ERROR_STRING_LEN
];
snprintf
(
err_str
,
ERROR_STRING_LEN
-
1
,
"Insert duplicate with tag: %s"
,
tag
.
c_str
());
RAW_LOG
(
ERROR
,
err_str
);
return
-
1
;
return
-
1
;
}
}
std
::
pair
<
typename
std
::
map
<
std
::
string
,
FactoryBase
<
B
>*>::
iterator
,
bool
>
std
::
pair
<
typename
std
::
map
<
std
::
string
,
FactoryBase
<
B
>*>::
iterator
,
bool
>
r
=
_pool
.
insert
(
std
::
make_pair
(
tag
,
factory
));
r
=
_pool
.
insert
(
std
::
make_pair
(
tag
,
factory
));
if
(
!
r
.
second
)
{
if
(
!
r
.
second
)
{
RAW_LOG_ERROR
(
"Failed insert new factory with: %s"
,
tag
.
c_str
());
char
err_str
[
ERROR_STRING_LEN
];
snprintf
(
err_str
,
ERROR_STRING_LEN
-
1
,
"Failed insert new factory with: %s"
,
tag
.
c_str
());
RAW_LOG
(
ERROR
,
err_str
);
return
-
1
;
return
-
1
;
}
}
...
@@ -164,9 +184,11 @@ class FactoryPool {
...
@@ -164,9 +184,11 @@ class FactoryPool {
typename
std
::
map
<
std
::
string
,
FactoryBase
<
B
>*>::
iterator
it
=
typename
std
::
map
<
std
::
string
,
FactoryBase
<
B
>*>::
iterator
it
=
_pool
.
find
(
tag
);
_pool
.
find
(
tag
);
if
(
it
==
_pool
.
end
()
||
it
->
second
==
NULL
)
{
if
(
it
==
_pool
.
end
()
||
it
->
second
==
NULL
)
{
RAW_LOG_ERROR
(
"Not found factory pool, tag: %s, pool size: %u"
,
char
err_str
[
ERROR_STRING_LEN
];
tag
.
c_str
(),
snprintf
(
err_str
,
ERROR_STRING_LEN
-
1
,
_pool
.
size
());
"Not found factory pool, tag: %s, pool size: %u"
,
tag
.
c_str
(),
_pool
.
size
());
RAW_LOG
(
ERROR
,
err_str
);
return
NULL
;
return
NULL
;
}
}
...
...
paddle_inference/inferencer-fluid-cpu/include/fluid_cpu_engine.h
浏览文件 @
a27774f2
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include "core/configure/inferencer_configure.pb.h"
#include "core/configure/inferencer_configure.pb.h"
#include "core/predictor/framework/infer.h"
#include "core/predictor/framework/infer.h"
#include "paddle_inference_api.h" // NOLINT
#include "paddle_inference_api.h" // NOLINT
//#include "predictor/framework/infer.h"
namespace
baidu
{
namespace
baidu
{
namespace
paddle_serving
{
namespace
paddle_serving
{
...
...
python/paddle_serving_server/__init__.py
浏览文件 @
a27774f2
...
@@ -157,6 +157,8 @@ class Server(object):
...
@@ -157,6 +157,8 @@ class Server(object):
self
.
cur_path
=
os
.
getcwd
()
self
.
cur_path
=
os
.
getcwd
()
self
.
use_local_bin
=
False
self
.
use_local_bin
=
False
self
.
mkl_flag
=
False
self
.
mkl_flag
=
False
self
.
product_name
=
None
self
.
container_id
=
None
self
.
model_config_paths
=
None
# for multi-model in a workflow
self
.
model_config_paths
=
None
# for multi-model in a workflow
def
set_max_concurrency
(
self
,
concurrency
):
def
set_max_concurrency
(
self
,
concurrency
):
...
@@ -191,6 +193,16 @@ class Server(object):
...
@@ -191,6 +193,16 @@ class Server(object):
def
set_ir_optimize
(
self
,
flag
=
False
):
def
set_ir_optimize
(
self
,
flag
=
False
):
self
.
ir_optimization
=
flag
self
.
ir_optimization
=
flag
def
set_product_name
(
self
,
product_name
=
None
):
if
product_name
==
None
:
raise
ValueError
(
"product_name can't be None."
)
self
.
product_name
=
product_name
def
set_container_id
(
self
,
container_id
):
if
container_id
==
None
:
raise
ValueError
(
"container_id can't be None."
)
self
.
container_id
=
container_id
def
check_local_bin
(
self
):
def
check_local_bin
(
self
):
if
"SERVING_BIN"
in
os
.
environ
:
if
"SERVING_BIN"
in
os
.
environ
:
self
.
use_local_bin
=
True
self
.
use_local_bin
=
True
...
@@ -254,6 +266,10 @@ class Server(object):
...
@@ -254,6 +266,10 @@ class Server(object):
self
.
resource_conf
.
model_toolkit_file
=
self
.
model_toolkit_fn
self
.
resource_conf
.
model_toolkit_file
=
self
.
model_toolkit_fn
self
.
resource_conf
.
general_model_path
=
workdir
self
.
resource_conf
.
general_model_path
=
workdir
self
.
resource_conf
.
general_model_file
=
self
.
general_model_config_fn
self
.
resource_conf
.
general_model_file
=
self
.
general_model_config_fn
if
self
.
product_name
!=
None
:
self
.
resource_conf
.
auth_product_name
=
self
.
product_name
if
self
.
container_id
!=
None
:
self
.
resource_conf
.
auth_container_id
=
self
.
container_id
def
_write_pb_str
(
self
,
filepath
,
pb_obj
):
def
_write_pb_str
(
self
,
filepath
,
pb_obj
):
with
open
(
filepath
,
"w"
)
as
fout
:
with
open
(
filepath
,
"w"
)
as
fout
:
...
@@ -540,7 +556,6 @@ class MultiLangServerServiceServicer(multi_lang_general_model_service_pb2_grpc.
...
@@ -540,7 +556,6 @@ class MultiLangServerServiceServicer(multi_lang_general_model_service_pb2_grpc.
results
,
tag
=
ret
results
,
tag
=
ret
resp
.
tag
=
tag
resp
.
tag
=
tag
resp
.
err_code
=
0
resp
.
err_code
=
0
if
not
self
.
is_multi_model_
:
if
not
self
.
is_multi_model_
:
results
=
{
'general_infer_0'
:
results
}
results
=
{
'general_infer_0'
:
results
}
for
model_name
,
model_result
in
results
.
items
():
for
model_name
,
model_result
in
results
.
items
():
...
...
python/paddle_serving_server/serve.py
浏览文件 @
a27774f2
...
@@ -58,6 +58,16 @@ def parse_args(): # pylint: disable=doc-string-missing
...
@@ -58,6 +58,16 @@ def parse_args(): # pylint: disable=doc-string-missing
default
=
False
,
default
=
False
,
action
=
"store_true"
,
action
=
"store_true"
,
help
=
"Use Multi-language-service"
)
help
=
"Use Multi-language-service"
)
parser
.
add_argument
(
"--product_name"
,
type
=
str
,
default
=
None
,
help
=
"product_name for authentication"
)
parser
.
add_argument
(
"--container_id"
,
type
=
str
,
default
=
None
,
help
=
"container_id for authentication"
)
return
parser
.
parse_args
()
return
parser
.
parse_args
()
...
@@ -101,6 +111,10 @@ def start_standard_model(): # pylint: disable=doc-string-missing
...
@@ -101,6 +111,10 @@ def start_standard_model(): # pylint: disable=doc-string-missing
server
.
use_mkl
(
use_mkl
)
server
.
use_mkl
(
use_mkl
)
server
.
set_max_body_size
(
max_body_size
)
server
.
set_max_body_size
(
max_body_size
)
server
.
set_port
(
port
)
server
.
set_port
(
port
)
if
args
.
product_name
!=
None
:
server
.
set_product_name
(
args
.
product_name
)
if
args
.
container_id
!=
None
:
server
.
set_container_id
(
args
.
container_id
)
server
.
load_model_config
(
model
)
server
.
load_model_config
(
model
)
server
.
prepare_server
(
workdir
=
workdir
,
port
=
port
,
device
=
device
)
server
.
prepare_server
(
workdir
=
workdir
,
port
=
port
,
device
=
device
)
...
...
python/paddle_serving_server_gpu/__init__.py
浏览文件 @
a27774f2
...
@@ -73,6 +73,16 @@ def serve_args():
...
@@ -73,6 +73,16 @@ def serve_args():
default
=
False
,
default
=
False
,
action
=
"store_true"
,
action
=
"store_true"
,
help
=
"Use Multi-language-service"
)
help
=
"Use Multi-language-service"
)
parser
.
add_argument
(
"--product_name"
,
type
=
str
,
default
=
None
,
help
=
"product_name for authentication"
)
parser
.
add_argument
(
"--container_id"
,
type
=
str
,
default
=
None
,
help
=
"container_id for authentication"
)
return
parser
.
parse_args
()
return
parser
.
parse_args
()
...
@@ -196,6 +206,8 @@ class Server(object):
...
@@ -196,6 +206,8 @@ class Server(object):
self
.
use_local_bin
=
False
self
.
use_local_bin
=
False
self
.
gpuid
=
0
self
.
gpuid
=
0
self
.
model_config_paths
=
None
# for multi-model in a workflow
self
.
model_config_paths
=
None
# for multi-model in a workflow
self
.
product_name
=
None
self
.
container_id
=
None
def
set_max_concurrency
(
self
,
concurrency
):
def
set_max_concurrency
(
self
,
concurrency
):
self
.
max_concurrency
=
concurrency
self
.
max_concurrency
=
concurrency
...
@@ -229,6 +241,16 @@ class Server(object):
...
@@ -229,6 +241,16 @@ class Server(object):
def
set_ir_optimize
(
self
,
flag
=
False
):
def
set_ir_optimize
(
self
,
flag
=
False
):
self
.
ir_optimization
=
flag
self
.
ir_optimization
=
flag
def
set_product_name
(
self
,
product_name
=
None
):
if
product_name
==
None
:
raise
ValueError
(
"product_name can't be None."
)
self
.
product_name
=
product_name
def
set_container_id
(
self
,
container_id
):
if
container_id
==
None
:
raise
ValueError
(
"container_id can't be None."
)
self
.
container_id
=
container_id
def
check_local_bin
(
self
):
def
check_local_bin
(
self
):
if
"SERVING_BIN"
in
os
.
environ
:
if
"SERVING_BIN"
in
os
.
environ
:
self
.
use_local_bin
=
True
self
.
use_local_bin
=
True
...
@@ -302,6 +324,10 @@ class Server(object):
...
@@ -302,6 +324,10 @@ class Server(object):
self
.
resource_conf
.
model_toolkit_file
=
self
.
model_toolkit_fn
self
.
resource_conf
.
model_toolkit_file
=
self
.
model_toolkit_fn
self
.
resource_conf
.
general_model_path
=
workdir
self
.
resource_conf
.
general_model_path
=
workdir
self
.
resource_conf
.
general_model_file
=
self
.
general_model_config_fn
self
.
resource_conf
.
general_model_file
=
self
.
general_model_config_fn
if
self
.
product_name
!=
None
:
self
.
resource_conf
.
auth_product_name
=
self
.
product_name
if
self
.
container_id
!=
None
:
self
.
resource_conf
.
auth_container_id
=
self
.
container_id
def
_write_pb_str
(
self
,
filepath
,
pb_obj
):
def
_write_pb_str
(
self
,
filepath
,
pb_obj
):
with
open
(
filepath
,
"w"
)
as
fout
:
with
open
(
filepath
,
"w"
)
as
fout
:
...
...
python/paddle_serving_server_gpu/serve.py
浏览文件 @
a27774f2
...
@@ -34,7 +34,7 @@ def start_gpu_card_model(index, gpuid, args): # pylint: disable=doc-string-miss
...
@@ -34,7 +34,7 @@ def start_gpu_card_model(index, gpuid, args): # pylint: disable=doc-string-miss
port
=
args
.
port
+
index
port
=
args
.
port
+
index
thread_num
=
args
.
thread
thread_num
=
args
.
thread
model
=
args
.
model
model
=
args
.
model
mem_optim
=
args
.
mem_optim_off
is
False
mem_optim
=
args
.
mem_optim_off
ir_optim
=
args
.
ir_optim
ir_optim
=
args
.
ir_optim
max_body_size
=
args
.
max_body_size
max_body_size
=
args
.
max_body_size
use_multilang
=
args
.
use_multilang
use_multilang
=
args
.
use_multilang
...
@@ -65,6 +65,11 @@ def start_gpu_card_model(index, gpuid, args): # pylint: disable=doc-string-miss
...
@@ -65,6 +65,11 @@ def start_gpu_card_model(index, gpuid, args): # pylint: disable=doc-string-miss
server
.
set_ir_optimize
(
ir_optim
)
server
.
set_ir_optimize
(
ir_optim
)
server
.
set_max_body_size
(
max_body_size
)
server
.
set_max_body_size
(
max_body_size
)
if
args
.
product_name
!=
None
:
server
.
set_product_name
(
args
.
product_name
)
if
args
.
container_id
!=
None
:
server
.
set_container_id
(
args
.
container_id
)
server
.
load_model_config
(
model
)
server
.
load_model_config
(
model
)
server
.
prepare_server
(
workdir
=
workdir
,
port
=
port
,
device
=
device
)
server
.
prepare_server
(
workdir
=
workdir
,
port
=
port
,
device
=
device
)
if
gpuid
>=
0
:
if
gpuid
>=
0
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录