Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
ba9f4c78
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ba9f4c78
编写于
3月 22, 2018
作者:
Y
Yancey1989
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix test_recv_op
上级
ee7f1ecd
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
17 addition
and
17 deletion
+17
-17
python/paddle/fluid/layers/io.py
python/paddle/fluid/layers/io.py
+8
-9
python/paddle/fluid/tests/unittests/test_recv_op.py
python/paddle/fluid/tests/unittests/test_recv_op.py
+9
-8
未找到文件。
python/paddle/fluid/layers/io.py
浏览文件 @
ba9f4c78
...
@@ -113,9 +113,9 @@ class ListenAndServ(object):
...
@@ -113,9 +113,9 @@ class ListenAndServ(object):
which can receive variables from clients and run a block.
which can receive variables from clients and run a block.
"""
"""
def
__init__
(
self
,
endpoint
,
fan_in
=
1
,
optimizer_mode
=
True
):
def
__init__
(
self
,
endpoint
,
inputs
,
fan_in
=
1
,
optimizer_mode
=
True
):
self
.
helper
=
LayerHelper
(
"listen_and_serv"
)
self
.
helper
=
LayerHelper
(
"listen_and_serv"
)
self
.
inputs
=
[]
self
.
inputs
=
inputs
self
.
outputs
=
[]
self
.
outputs
=
[]
self
.
endpoint
=
endpoint
self
.
endpoint
=
endpoint
self
.
fan_in
=
fan_in
self
.
fan_in
=
fan_in
...
@@ -160,18 +160,13 @@ class ListenAndServ(object):
...
@@ -160,18 +160,13 @@ class ListenAndServ(object):
current_block
=
main_program
.
current_block
()
current_block
=
main_program
.
current_block
()
parent_block
=
self
.
parent_block
()
parent_block
=
self
.
parent_block
()
params
,
grads
=
self
.
get_params_and_grads
()
param_names
=
[
p
.
name
for
p
in
params
]
grad_names
=
[
g
.
name
for
g
in
grads
]
parent_block
.
append_op
(
parent_block
.
append_op
(
type
=
'listen_and_serv'
,
type
=
'listen_and_serv'
,
inputs
=
{},
inputs
=
{
"X"
:
self
.
inputs
},
outputs
=
{},
outputs
=
{},
attrs
=
{
attrs
=
{
'endpoint'
:
self
.
endpoint
,
'endpoint'
:
self
.
endpoint
,
'Fanin'
:
self
.
fan_in
,
'Fanin'
:
self
.
fan_in
,
'ParamList'
:
param_names
,
'GradList'
:
grad_names
,
'OptimizeBlock'
:
current_block
'OptimizeBlock'
:
current_block
})
})
...
@@ -196,10 +191,14 @@ def Send(endpoints, send_vars, get_vars):
...
@@ -196,10 +191,14 @@ def Send(endpoints, send_vars, get_vars):
endpoints
=
list
(
set
(
epmap
))
endpoints
=
list
(
set
(
epmap
))
helper
=
LayerHelper
(
"Send"
,
**
locals
())
helper
=
LayerHelper
(
"Send"
,
**
locals
())
rpc_client_var
=
default_main_program
().
global_block
().
create_var
(
name
=
"RPC_CLIENT_VAR"
,
persistable
=
True
,
type
=
core
.
VarDesc
.
VarType
.
RAW
)
helper
.
append_op
(
helper
.
append_op
(
type
=
"send"
,
type
=
"send"
,
inputs
=
{
"X"
:
send_vars
},
inputs
=
{
"X"
:
send_vars
},
outputs
=
{
"Out"
:
get_vars
},
outputs
=
{
"Out"
:
get_vars
,
"RPCClient"
:
rpc_client_var
},
attrs
=
{
"endpoints"
:
endpoints
,
attrs
=
{
"endpoints"
:
endpoints
,
"epmap"
:
epmap
})
"epmap"
:
epmap
})
...
...
python/paddle/fluid/tests/unittests/test_recv_op.py
浏览文件 @
ba9f4c78
...
@@ -32,20 +32,21 @@ class TestRecvOp(unittest.TestCase):
...
@@ -32,20 +32,21 @@ class TestRecvOp(unittest.TestCase):
time
.
sleep
(
1
)
time
.
sleep
(
1
)
self
.
init_client
(
place
)
self
.
init_client
(
place
)
# FIXME(typhoonzero): find a way to gracefully shutdown the server.
# FIXME(typhoonzero): find a way to gracefully shutdown the server.
os
.
system
(
"kill -9 %d"
%
p
.
pid
)
#
os.system("kill -9 %d" % p.pid)
p
.
join
()
p
.
join
()
def
init_serv
(
self
,
place
):
def
init_serv
(
self
,
place
):
main
=
fluid
.
Program
()
main
=
fluid
.
Program
()
with
fluid
.
program_guard
(
main
):
with
fluid
.
program_guard
(
main
):
x
=
layers
.
data
(
serv
=
layers
.
ListenAndServ
(
shape
=
[
32
,
32
],
"127.0.0.1:6174"
,
[
"X"
],
optimizer_mode
=
False
)
dtype
=
'float32'
,
name
=
"X"
,
append_batch_size
=
False
)
fluid
.
initializer
.
Constant
(
value
=
1.0
)(
x
,
main
.
global_block
())
serv
=
layers
.
ListenAndServ
(
"127.0.0.1:6174"
,
optimizer_mode
=
False
)
with
serv
.
do
():
with
serv
.
do
():
x
=
layers
.
data
(
shape
=
[
32
,
32
],
dtype
=
'float32'
,
name
=
"X"
,
append_batch_size
=
False
)
fluid
.
initializer
.
Constant
(
value
=
1.0
)(
x
,
main
.
global_block
())
o
=
layers
.
scale
(
x
=
x
,
scale
=
10.0
)
o
=
layers
.
scale
(
x
=
x
,
scale
=
10.0
)
main
.
global_block
().
create_var
(
main
.
global_block
().
create_var
(
name
=
o
.
name
,
psersistable
=
False
,
dtype
=
o
.
dtype
,
shape
=
o
.
shape
)
name
=
o
.
name
,
psersistable
=
False
,
dtype
=
o
.
dtype
,
shape
=
o
.
shape
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录