Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
563421e7
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看板
未验证
提交
563421e7
编写于
6月 03, 2021
作者:
J
Jiawei Wang
提交者:
GitHub
6月 03, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into develop
上级
714c795b
4cd9a949
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
18 addition
and
22 deletion
+18
-22
core/general-client/src/general_model.cpp
core/general-client/src/general_model.cpp
+6
-13
python/paddle_serving_client/client.py
python/paddle_serving_client/client.py
+11
-8
python/paddle_serving_server/rpc_service.py
python/paddle_serving_server/rpc_service.py
+1
-1
未找到文件。
core/general-client/src/general_model.cpp
浏览文件 @
563421e7
...
...
@@ -18,7 +18,6 @@
#include "core/sdk-cpp/include/common.h"
#include "core/sdk-cpp/include/predictor_sdk.h"
#include "core/util/include/timer.h"
DEFINE_bool
(
profile_client
,
false
,
""
);
DEFINE_bool
(
profile_server
,
false
,
""
);
...
...
@@ -46,7 +45,7 @@ void PredictorClient::init_gflags(std::vector<std::string> argv) {
int
argc
=
argv
.
size
();
char
**
arr
=
new
char
*
[
argv
.
size
()];
std
::
string
line
;
for
(
size_t
i
=
0
;
i
<
argv
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
argv
.
size
();
++
i
)
{
arr
[
i
]
=
&
argv
[
i
][
0
];
line
+=
argv
[
i
];
line
+=
' '
;
...
...
@@ -189,7 +188,6 @@ int PredictorClient::numpy_predict(
}
int
vec_idx
=
0
;
for
(
int
bi
=
0
;
bi
<
batch_size
;
bi
++
)
{
VLOG
(
2
)
<<
"prepare batch "
<<
bi
;
std
::
vector
<
Tensor
*>
tensor_vec
;
...
...
@@ -220,11 +218,10 @@ int PredictorClient::numpy_predict(
return
-
1
;
}
int
nbytes
=
float_feed
[
vec_idx
].
nbytes
();
// int ndims = float_feed[vec_idx].ndim();
void
*
rawdata_ptr
=
(
void
*
)
float_feed
[
vec_idx
].
data
(
0
);
void
*
rawdata_ptr
=
(
void
*
)(
float_feed
[
vec_idx
].
data
(
0
));
int
total_number
=
float_feed
[
vec_idx
].
size
();
// float* end_ptr = (rawdata_ptr + total_number);
Tensor
*
tensor
=
tensor_vec
[
idx
];
VLOG
(
2
)
<<
"prepare float feed "
<<
name
<<
" shape size "
<<
float_shape
[
vec_idx
].
size
();
for
(
uint32_t
j
=
0
;
j
<
float_shape
[
vec_idx
].
size
();
++
j
)
{
...
...
@@ -234,6 +231,7 @@ int PredictorClient::numpy_predict(
tensor
->
add_lod
(
float_lod_slot_batch
[
vec_idx
][
j
]);
}
tensor
->
set_elem_type
(
P_FLOAT32
);
tensor
->
mutable_float_data
()
->
Resize
(
total_number
,
0
);
memcpy
(
tensor
->
mutable_float_data
()
->
mutable_data
(),
rawdata_ptr
,
nbytes
);
vec_idx
++
;
...
...
@@ -251,7 +249,7 @@ int PredictorClient::numpy_predict(
}
Tensor
*
tensor
=
tensor_vec
[
idx
];
int
nbytes
=
int_feed
[
vec_idx
].
nbytes
();
void
*
rawdata_ptr
=
(
void
*
)
int_feed
[
vec_idx
].
data
(
0
);
void
*
rawdata_ptr
=
(
void
*
)
(
int_feed
[
vec_idx
].
data
(
0
)
);
int
total_number
=
int_feed
[
vec_idx
].
size
();
for
(
uint32_t
j
=
0
;
j
<
int_shape
[
vec_idx
].
size
();
++
j
)
{
...
...
@@ -263,19 +261,14 @@ int PredictorClient::numpy_predict(
tensor
->
set_elem_type
(
_type
[
idx
]);
if
(
_type
[
idx
]
==
P_INT64
)
{
VLOG
(
2
)
<<
"prepare int feed "
<<
name
<<
" shape size "
<<
int_shape
[
vec_idx
].
size
();
tensor
->
mutable_int64_data
()
->
Resize
(
total_number
,
0
);
memcpy
(
tensor
->
mutable_int64_data
()
->
mutable_data
(),
rawdata_ptr
,
nbytes
);
vec_idx
++
;
}
else
{
VLOG
(
2
)
<<
"prepare int32 feed "
<<
name
<<
" shape size "
<<
int_shape
[
vec_idx
].
size
();
tensor
->
mutable_int_data
()
->
Resize
(
total_number
,
0
);
memcpy
(
tensor
->
mutable_int_data
()
->
mutable_data
(),
rawdata_ptr
,
nbytes
);
vec_idx
++
;
}
vec_idx
++
;
}
VLOG
(
2
)
<<
"batch ["
<<
bi
<<
"] "
...
...
python/paddle_serving_client/client.py
浏览文件 @
563421e7
...
...
@@ -356,7 +356,8 @@ class Client(object):
int_feed_names
.
append
(
key
)
shape_lst
=
[]
if
batch
==
False
:
feed_i
[
key
]
=
feed_i
[
key
][
np
.
newaxis
,
:]
feed_i
[
key
]
=
np
.
expand_dims
(
feed_i
[
key
],
0
).
repeat
(
1
,
axis
=
0
)
if
isinstance
(
feed_i
[
key
],
np
.
ndarray
):
shape_lst
.
extend
(
list
(
feed_i
[
key
].
shape
))
int_shape
.
append
(
shape_lst
)
...
...
@@ -369,10 +370,10 @@ class Client(object):
int_lod_slot_batch
.
append
([])
if
isinstance
(
feed_i
[
key
],
np
.
ndarray
):
int_slot
.
append
(
feed_i
[
key
]
)
int_slot
.
append
(
np
.
ascontiguousarray
(
feed_i
[
key
])
)
self
.
has_numpy_input
=
True
else
:
int_slot
.
append
(
feed_i
[
key
]
)
int_slot
.
append
(
np
.
ascontiguousarray
(
feed_i
[
key
])
)
self
.
all_numpy_input
=
False
elif
self
.
feed_types_
[
key
]
in
float_type
:
...
...
@@ -380,7 +381,8 @@ class Client(object):
float_feed_names
.
append
(
key
)
shape_lst
=
[]
if
batch
==
False
:
feed_i
[
key
]
=
feed_i
[
key
][
np
.
newaxis
,
:]
feed_i
[
key
]
=
np
.
expand_dims
(
feed_i
[
key
],
0
).
repeat
(
1
,
axis
=
0
)
if
isinstance
(
feed_i
[
key
],
np
.
ndarray
):
shape_lst
.
extend
(
list
(
feed_i
[
key
].
shape
))
float_shape
.
append
(
shape_lst
)
...
...
@@ -393,10 +395,10 @@ class Client(object):
float_lod_slot_batch
.
append
([])
if
isinstance
(
feed_i
[
key
],
np
.
ndarray
):
float_slot
.
append
(
feed_i
[
key
]
)
float_slot
.
append
(
np
.
ascontiguousarray
(
feed_i
[
key
])
)
self
.
has_numpy_input
=
True
else
:
float_slot
.
append
(
feed_i
[
key
]
)
float_slot
.
append
(
np
.
ascontiguousarray
(
feed_i
[
key
])
)
self
.
all_numpy_input
=
False
#if input is string, feed is not numpy.
elif
self
.
feed_types_
[
key
]
in
string_type
:
...
...
@@ -408,7 +410,7 @@ class Client(object):
key
)])
else
:
string_lod_slot_batch
.
append
([])
string_slot
.
append
(
feed_i
[
key
]
)
string_slot
.
append
(
np
.
ascontiguousarray
(
feed_i
[
key
])
)
self
.
has_numpy_input
=
True
int_slot_batch
.
append
(
int_slot
)
int_lod_slot_batch
.
append
(
int_lod_slot
)
...
...
@@ -626,6 +628,7 @@ class MultiLangClient(object):
raise
Exception
(
"error tensor value type."
)
else
:
raise
Exception
(
"var must be list or ndarray."
)
data
=
np
.
ascontiguousarray
(
data
)
tensor
.
data
=
data
.
tobytes
()
tensor
.
shape
.
extend
(
list
(
var
.
shape
))
if
"{}.lod"
.
format
(
name
)
in
feed
.
keys
():
...
...
@@ -700,7 +703,7 @@ class MultiLangClient(object):
if
batch
is
False
:
for
key
in
feed
:
if
".lod"
not
in
key
:
feed
[
key
]
=
feed
[
key
][
np
.
newaxis
,
:]
feed
[
key
]
=
np
.
expand_dims
(
feed
[
key
],
0
).
repeat
(
1
,
axis
=
0
)
if
not
asyn
:
try
:
self
.
profile_
.
record
(
'py_prepro_0'
)
...
...
python/paddle_serving_server/rpc_service.py
浏览文件 @
563421e7
...
...
@@ -126,7 +126,7 @@ class MultiLangServerServiceServicer(multi_lang_general_model_service_pb2_grpc.
else
:
raise
Exception
(
"error type."
)
data
.
shape
=
list
(
feed_inst
.
tensor_array
[
idx
].
shape
)
feed_dict
[
name
]
=
data
feed_dict
[
name
]
=
np
.
ascontiguousarray
(
data
)
if
len
(
var
.
lod
)
>
0
:
feed_dict
[
"{}.lod"
.
format
(
name
)]
=
var
.
lod
feed_batch
.
append
(
feed_dict
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录