Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
efbe29a7
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看板
提交
efbe29a7
编写于
6月 23, 2020
作者:
B
barrierye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[WIP] update code
上级
87e300a0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
69 addition
and
9 deletion
+69
-9
java/paddle-serving-sdk-java/src/main/java/io/paddle/serving/client/Client.java
...k-java/src/main/java/io/paddle/serving/client/Client.java
+69
-9
未找到文件。
java/paddle-serving-sdk-java/src/main/java/io/paddle/serving/client/Client.java
浏览文件 @
efbe29a7
...
...
@@ -61,7 +61,7 @@ public class Client {
return
resp
.
getErrCode
()
==
0
;
}
public
Boolean
connect
(
String
[]
endpoints
)
{
public
Boolean
connect
(
List
<
String
>
endpoints
)
{
String
target
=
"ipv4:"
+
String
.
join
(
","
,
endpoints
);
// TODO: max_receive_message_length and max_send_message_length
try
{
...
...
@@ -233,14 +233,61 @@ public class Client {
}
}
// TODO: tag
return
multi_result_map
;
}
/*
public Map<String, ? extends Map<String, List<? extends Number>>> predict(
List
<
Map
<
String
,
List
<?
extends
Number
>>>
feed
,
Map<String, List<? extends Number>> feed,
Iterable<String> fetch) {
return predict(feed, fetch, false);
}
public PredictFuture async_predict(
Map<String, List<? extends Number>> feed,
Iterable<String> fetch) {
return async_predict(feed, fetch, false);
}
public Map<String, ? extends Map<String, List<? extends Number>>> predict(
Map<String, List<? extends Number>> feed,
Iterable<String> fetch,
Boolean need_variant_tag) {
InferenceRequest
req
=
_packInferenceRequest
(
feed
,
fetch
);
List<? extends Map<String, List<? extends Number>>> feed_batch
= new ArrayList<? extends Map<String, List<? extends Number>>>();
feed_batch.add(feed);
return predict(feed_batch, fetch, need_variant_tag);
}
public PredictFuture async_predict(
Map<String, List<? extends Number>> feed,
Iterable<String> fetch,
Boolean need_variant_tag) {
List<? extends Map<String, List<? extends Number>>> feed_batch
= new ArrayList<? extends Map<String, List<? extends Number>>>();
feed_batch.add(feed);
return async_predict(feed_batch, fetch, need_variant_tag);
}
*/
public
Map
<
String
,
?
extends
Map
<
String
,
List
<?
extends
Number
>>>
predict
(
List
<?
extends
Map
<
String
,
List
<?
extends
Number
>>>
feed_batch
,
Iterable
<
String
>
fetch
)
{
return
predict
(
feed_batch
,
fetch
,
false
);
}
public
PredictFuture
async_predict
(
List
<?
extends
Map
<
String
,
List
<?
extends
Number
>>>
feed_batch
,
Iterable
<
String
>
fetch
)
{
return
async_predict
(
feed_batch
,
fetch
,
false
);
}
public
Map
<
String
,
?
extends
Map
<
String
,
List
<?
extends
Number
>>>
predict
(
List
<?
extends
Map
<
String
,
List
<?
extends
Number
>>>
feed_batch
,
Iterable
<
String
>
fetch
,
Boolean
need_variant_tag
)
{
InferenceRequest
req
=
_packInferenceRequest
(
feed_batch
,
fetch
);
try
{
InferenceResponse
resp
=
blockingStub_
.
inference
(
req
);
return
_unpackInferenceResponse
(
...
...
@@ -252,15 +299,11 @@ public class Client {
}
public
PredictFuture
async_predict
(
List
<
Map
<
String
,
List
<?
extends
Number
>>>
feed
,
List
<
Map
<
String
,
List
<?
extends
Number
>>>
feed
_batch
,
Iterable
<
String
>
fetch
,
Boolean
need_variant_tag
)
{
InferenceRequest
req
=
_packInferenceRequest
(
feed
,
fetch
);
InferenceRequest
req
=
_packInferenceRequest
(
feed
_batch
,
fetch
);
ListenableFuture
<
InferenceResponse
>
future
=
futureStub_
.
inference
(
req
);
// Function<InferenceResponse,
// Map<String, ? extends Map<String, List<? extends Number>>>>
// call_back_func = partial(
// Client::_unpackInferenceResponse, fetch, need_variant_tag);
return
new
PredictFuture
(
future
,
(
InferenceResponse
resp
)
->
{
...
...
@@ -270,6 +313,23 @@ public class Client {
}
public
static
void
main
(
String
[]
args
)
{
Client
client
=
new
Client
();
List
<
String
>
endpoints
=
new
ArrayList
<
String
>()
.
add
(
"182.61.111.54:9393"
);
Client
.
connect
(
endpoints
);
List
<
HashMap
<
String
,
List
<
Float
>>>
feed_batch
=
new
ArrayList
<
HashMap
<
String
,
List
<
Float
>>>()
.
add
(
new
HashMap
<
String
,
ArrayList
<
Float
>>()
.
put
(
"x"
,
new
ArrayList
<
Float
>()
.
add
(
0.0137f
).
add
(-
0.1136f
).
add
(
0.2553f
)
.
add
(-
0.0692f
).
add
(
0.0582f
).
add
(-
0.0727f
)
.
add
(-
0.1583f
).
add
(-
0.0584f
).
add
(
0.6283f
)
.
add
(
0.4919f
).
add
(
0.1856f
).
add
(
0.0795f
)
.
add
(-
0.0332f
)));
List
<
String
>
fetch
=
new
ArrayList
<
String
>()
.
add
(
"price"
);
Map
<
String
,
?
extends
Map
<
String
,
List
<?>>>
fetch_map
=
client
.
predict
(
feed_batch
,
fetch
);
System
.
out
.
println
(
"Hello World!"
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录