Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
3d088d05
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看板
提交
3d088d05
编写于
12月 31, 2019
作者:
G
guru4elephant
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add general model init
上级
77acea9d
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
104 addition
and
0 deletion
+104
-0
configure/CMakeLists.txt
configure/CMakeLists.txt
+1
-0
configure/proto/general_model_config.proto
configure/proto/general_model_config.proto
+26
-0
predictor/common/constant.h
predictor/common/constant.h
+3
-0
predictor/common/inner_common.h
predictor/common/inner_common.h
+1
-0
predictor/framework/resource.cpp
predictor/framework/resource.cpp
+36
-0
predictor/framework/resource.h
predictor/framework/resource.h
+26
-0
predictor/src/pdserving.cpp
predictor/src/pdserving.cpp
+11
-0
未找到文件。
configure/CMakeLists.txt
浏览文件 @
3d088d05
...
@@ -2,6 +2,7 @@ LIST(APPEND protofiles
...
@@ -2,6 +2,7 @@ LIST(APPEND protofiles
${
CMAKE_CURRENT_LIST_DIR
}
/proto/server_configure.proto
${
CMAKE_CURRENT_LIST_DIR
}
/proto/server_configure.proto
${
CMAKE_CURRENT_LIST_DIR
}
/proto/sdk_configure.proto
${
CMAKE_CURRENT_LIST_DIR
}
/proto/sdk_configure.proto
${
CMAKE_CURRENT_LIST_DIR
}
/proto/inferencer_configure.proto
${
CMAKE_CURRENT_LIST_DIR
}
/proto/inferencer_configure.proto
${
CMAKE_CURRENT_LIST_DIR
}
/proto/general_model_config.proto
)
)
PROTOBUF_GENERATE_CPP
(
configure_proto_srcs configure_proto_hdrs
${
protofiles
}
)
PROTOBUF_GENERATE_CPP
(
configure_proto_srcs configure_proto_hdrs
${
protofiles
}
)
...
...
configure/proto/general_model_config.proto
0 → 100644
浏览文件 @
3d088d05
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax
=
"proto2"
;
package
baidu
.
paddle_serving.configure
;
message
Shape
{
repeated
int32
shape
=
1
;
};
message
GeneralModelConfig
{
repeated
bool
is_lod_feed
=
1
;
repeated
int32
feed_type
=
2
;
repeated
Shape
feed_shape
=
4
;
};
predictor/common/constant.h
浏览文件 @
3d088d05
...
@@ -31,6 +31,8 @@ DECLARE_string(logger_path);
...
@@ -31,6 +31,8 @@ DECLARE_string(logger_path);
DECLARE_string
(
logger_file
);
DECLARE_string
(
logger_file
);
DECLARE_string
(
resource_path
);
DECLARE_string
(
resource_path
);
DECLARE_string
(
resource_file
);
DECLARE_string
(
resource_file
);
DECLARE_string
(
general_model_path
);
DECLARE_string
(
general_model_file
);
DECLARE_bool
(
enable_mc_cache
);
DECLARE_bool
(
enable_mc_cache
);
DECLARE_bool
(
enable_nshead_protocol
);
DECLARE_bool
(
enable_nshead_protocol
);
DECLARE_string
(
nshead_protocol
);
DECLARE_string
(
nshead_protocol
);
...
@@ -40,6 +42,7 @@ DECLARE_int32(reload_interval_s);
...
@@ -40,6 +42,7 @@ DECLARE_int32(reload_interval_s);
DECLARE_bool
(
enable_model_toolkit
);
DECLARE_bool
(
enable_model_toolkit
);
DECLARE_string
(
enable_protocol_list
);
DECLARE_string
(
enable_protocol_list
);
DECLARE_bool
(
enable_cube
);
DECLARE_bool
(
enable_cube
);
DECLARE_bool
(
enable_general_model
);
// STATIC Variables
// STATIC Variables
extern
const
char
*
START_OP_NAME
;
extern
const
char
*
START_OP_NAME
;
...
...
predictor/common/inner_common.h
浏览文件 @
3d088d05
...
@@ -54,6 +54,7 @@
...
@@ -54,6 +54,7 @@
#include "configure/include/configure_parser.h"
#include "configure/include/configure_parser.h"
#include "configure/server_configure.pb.h"
#include "configure/server_configure.pb.h"
#include "configure/general_model_config.pb.h"
#include "predictor/common/constant.h"
#include "predictor/common/constant.h"
#include "predictor/common/types.h"
#include "predictor/common/types.h"
...
...
predictor/framework/resource.cpp
浏览文件 @
3d088d05
...
@@ -21,6 +21,8 @@ namespace paddle_serving {
...
@@ -21,6 +21,8 @@ namespace paddle_serving {
namespace
predictor
{
namespace
predictor
{
using
configure
::
ResourceConf
;
using
configure
::
ResourceConf
;
using
configure
::
GeneralModelConf
;
using
configure
::
Shape
;
using
rec
::
mcube
::
CubeAPI
;
using
rec
::
mcube
::
CubeAPI
;
// __thread bool p_thread_initialized = false;
// __thread bool p_thread_initialized = false;
...
@@ -96,6 +98,40 @@ int Resource::initialize(const std::string& path, const std::string& file) {
...
@@ -96,6 +98,40 @@ int Resource::initialize(const std::string& path, const std::string& file) {
return
0
;
return
0
;
}
}
int
Resource
::
general_model_initialize
(
const
std
::
string
&
path
,
const
std
::
string
&
file
)
{
if
(
!
FLAGS_enable_general_model
)
{
return
0
;
}
GeneralModelConf
model_config
;
if
(
configure
::
read_proto_conf
(
path
,
file
,
&
model_config
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Failed initialize resource from: "
<<
path
<<
"/"
<<
file
;
return
-
1
;
}
_config
.
reset
(
new
PaddleGeneralModelConfig
());
_config
->
_feed_type
.
resize
(
model_config
.
is_feed_type_size
());
_config
->
_is_lod_feed
.
resize
(
model_config
.
is_lod_feed_size
());
_config
->
_capacity
.
resize
(
model_config
.
feed_shape_size
());
_config
->
_feed_shape
.
resize
(
model_config
.
feed_shape_size
());
for
(
int
i
=
0
;
i
<
model_config
.
is_lod_feed_size
();
++
i
)
{
_config
->
feed_type
[
i
]
=
model_config
.
feed_type
(
i
);
if
(
model_config
.
is_lod_feed
(
i
))
{
_config
->
_feed_shape
[
i
]
=
{
-
1
};
_config
->
_is_lod_feed
[
i
]
=
true
;
}
else
{
_config
->
capacity
[
i
]
=
1
;
_config
->
_is_lod_feed
[
i
]
=
false
;
for
(
int
j
=
0
;
j
<
model_config
.
feed_shape
(
i
).
shape_size
();
++
j
)
{
int
dim
=
model_cnofig
.
feed_shape
(
i
).
shape
(
j
);
_config
->
_feed_shape
[
i
].
push_back
(
dim
);
_config
->
capacity
[
i
]
*=
dim
;
}
}
}
}
int
Resource
::
cube_initialize
(
const
std
::
string
&
path
,
int
Resource
::
cube_initialize
(
const
std
::
string
&
path
,
const
std
::
string
&
file
)
{
const
std
::
string
&
file
)
{
// cube
// cube
...
...
predictor/framework/resource.h
浏览文件 @
3d088d05
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#pragma once
#pragma once
#include <memory>
#include <memory>
#include <string>
#include <string>
#include <vector>
#include "cube/cube-api/include/cube_api.h"
#include "cube/cube-api/include/cube_api.h"
#include "kvdb/paddle_rocksdb.h"
#include "kvdb/paddle_rocksdb.h"
#include "predictor/common/inner_common.h"
#include "predictor/common/inner_common.h"
...
@@ -25,6 +26,26 @@ namespace baidu {
...
@@ -25,6 +26,26 @@ namespace baidu {
namespace
paddle_serving
{
namespace
paddle_serving
{
namespace
predictor
{
namespace
predictor
{
class
PaddleGeneralModelConfig
{
PaddleGeneralModelConfig
();
~
PaddleGeneralModelConfig
();
void
load_config
(
std
::
string
);
public:
std
::
vector
<
int
>
_feed_type
;
// 0 int64, 1 float
std
::
vector
<
bool
>
_is_lod_feed
;
// true lod tensor
std
::
vector
<
int
>
_capacity
;
// capacity for each tensor
/*
feed_shape_ for feeded variable
feed_shape_[i][j] represents the jth dim for ith input Tensor
if is_lod_feed_[i] == False, feed_shape_[i][0] = -1
*/
std
::
vector
<
std
::
vector
<
int
>>
_feed_shape
;
};
class
BaseRdDict
;
class
BaseRdDict
;
struct
DynamicResource
{
struct
DynamicResource
{
DynamicResource
();
DynamicResource
();
...
@@ -55,6 +76,10 @@ class Resource {
...
@@ -55,6 +76,10 @@ class Resource {
int
initialize
(
const
std
::
string
&
path
,
const
std
::
string
&
file
);
int
initialize
(
const
std
::
string
&
path
,
const
std
::
string
&
file
);
int
cube_initialize
(
const
std
::
string
&
path
,
const
std
::
string
&
file
);
int
cube_initialize
(
const
std
::
string
&
path
,
const
std
::
string
&
file
);
int
general_model_initialize
(
const
std
::
string
&
path
,
const
std
::
string
&
file
);
int
thread_initialize
();
int
thread_initialize
();
int
thread_clear
();
int
thread_clear
();
...
@@ -73,6 +98,7 @@ class Resource {
...
@@ -73,6 +98,7 @@ class Resource {
private:
private:
int
thread_finalize
()
{
return
0
;
}
int
thread_finalize
()
{
return
0
;
}
std
::
shared_ptr
<
RocksDBWrapper
>
db
;
std
::
shared_ptr
<
RocksDBWrapper
>
db
;
std
::
shared_ptr
<
PaddleGeneralModelConfig
>
_config
;
THREAD_KEY_T
_tls_bspec_key
;
THREAD_KEY_T
_tls_bspec_key
;
};
};
...
...
predictor/src/pdserving.cpp
浏览文件 @
3d088d05
...
@@ -216,6 +216,17 @@ int main(int argc, char** argv) {
...
@@ -216,6 +216,17 @@ int main(int argc, char** argv) {
LOG
(
INFO
)
<<
"Succ initialize cube"
;
LOG
(
INFO
)
<<
"Succ initialize cube"
;
#ifndef BCLOUD
#ifndef BCLOUD
if
(
Resource
::
instance
().
general_model_initialize
(
FLAGS_general_model_path
,
FLAGS_general_model_file
)
!=
0
)
{
LOG
(
ERROR
)
<<
"Failed to initialize general model conf: "
<<
FLAGS_general_model_path
<<
"/"
<<
FLAGS_general_model_file
;
return
-
1
;
}
LOG
(
INFO
)
<<
"Succ initialize general model"
// FATAL messages are output to stderr
// FATAL messages are output to stderr
FLAGS_stderrthreshold
=
3
;
FLAGS_stderrthreshold
=
3
;
#endif
#endif
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录