Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
39f6274e
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
39f6274e
编写于
4月 22, 2018
作者:
Q
qiaolongfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
follow comment, optimize code
上级
e05f4dfb
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
14 addition
and
19 deletion
+14
-19
python/paddle/fluid/distribute_transpiler.py
python/paddle/fluid/distribute_transpiler.py
+10
-19
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+4
-0
未找到文件。
python/paddle/fluid/distribute_transpiler.py
浏览文件 @
39f6274e
...
@@ -371,22 +371,18 @@ class DistributeTranspiler:
...
@@ -371,22 +371,18 @@ class DistributeTranspiler:
recv_inputs
.
append
(
single_trainer_var
)
recv_inputs
.
append
(
single_trainer_var
)
# step 3
# step 3
# each optimization op will has a optimize block
optimize_block
=
None
# step 4
# Create a union-find data structure from optimize ops,
# Create a union-find data structure from optimize ops,
# If two ops are connected, we could add these two ops
# If two ops are connected, we could add these two ops
# into one set.
# into one set.
ufind
=
self
.
_create_ufind
(
self
.
optimize_ops
)
ufind
=
self
.
_create_ufind
(
self
.
optimize_ops
)
# step
4
.2
# step
3
.2
# Iterate through the ops and append optimize op which
# Iterate through the ops and append optimize op which
# located on current pserver
# located on current pserver
opt_op_on_pserver
=
[]
opt_op_on_pserver
=
[]
for
_
,
op
in
enumerate
(
self
.
optimize_ops
):
for
_
,
op
in
enumerate
(
self
.
optimize_ops
):
if
self
.
_is_opt_op
(
op
)
and
self
.
_is_opt_op_on_pserver
(
endpoint
,
op
):
if
self
.
_is_opt_op
(
op
)
and
self
.
_is_opt_op_on_pserver
(
endpoint
,
op
):
opt_op_on_pserver
.
append
(
op
)
opt_op_on_pserver
.
append
(
op
)
# step
4
.3
# step
3
.3
# Iterate through the ops, and if an op and the optimize ops
# Iterate through the ops, and if an op and the optimize ops
# which located on current pserver are in one set, then
# which located on current pserver are in one set, then
# append it into the sub program.
# append it into the sub program.
...
@@ -420,23 +416,17 @@ class DistributeTranspiler:
...
@@ -420,23 +416,17 @@ class DistributeTranspiler:
self
.
_append_pserver_non_opt_ops
(
block
,
op
)
self
.
_append_pserver_non_opt_ops
(
block
,
op
)
# append lr decay ops to the child block if exists
# append lr decay ops to the child block if exists
lr_decay_block
=
None
lr_ops
=
self
.
_get_lr_ops
()
lr_ops
=
self
.
_get_lr_ops
()
if
len
(
lr_ops
)
>
0
:
if
len
(
lr_ops
)
>
0
:
lr_decay_block
=
pserver_program
.
create_block
(
GLOBAL_BLOCK_IDX
)
lr_decay_block
=
pserver_program
.
create_block
(
pserver_program
.
num_blocks
-
1
)
for
_
,
op
in
enumerate
(
lr_ops
):
for
_
,
op
in
enumerate
(
lr_ops
):
self
.
_append_pserver_non_opt_ops
(
lr_decay_block
,
op
)
self
.
_append_pserver_non_opt_ops
(
lr_decay_block
,
op
)
# append op to the current block
# append op to the current block
per_opt_block
=
None
pre_block_idx
=
pserver_program
.
num_blocks
-
1
pre_block_idx
=
GLOBAL_BLOCK_IDX
if
lr_decay_block
is
not
None
:
pre_block_idx
=
lr_decay_block
.
idx
for
idx
,
opt_op
in
enumerate
(
opt_op_on_pserver
):
for
idx
,
opt_op
in
enumerate
(
opt_op_on_pserver
):
per_opt_block
=
pserver_program
.
create_block
(
pre_block_idx
)
per_opt_block
=
pserver_program
.
create_block
(
pre_block_idx
)
if
optimize_block
is
None
:
# first optimize block
optimize_block
=
per_opt_block
for
_
,
op
in
enumerate
(
self
.
optimize_ops
):
for
_
,
op
in
enumerate
(
self
.
optimize_ops
):
# optimizer is connected to itself
# optimizer is connected to itself
if
ufind
.
is_connected
(
op
,
opt_op
)
and
op
not
in
global_ops
:
if
ufind
.
is_connected
(
op
,
opt_op
)
and
op
not
in
global_ops
:
...
@@ -445,7 +435,8 @@ class DistributeTranspiler:
...
@@ -445,7 +435,8 @@ class DistributeTranspiler:
# append global ops
# append global ops
opt_state_block
=
None
opt_state_block
=
None
if
global_ops
:
if
global_ops
:
opt_state_block
=
pserver_program
.
create_block
(
per_opt_block
.
idx
)
opt_state_block
=
pserver_program
.
create_block
(
pserver_program
.
num_blocks
-
1
)
for
glb_op
in
global_ops
:
for
glb_op
in
global_ops
:
__append_optimize_op__
(
glb_op
,
opt_state_block
)
__append_optimize_op__
(
glb_op
,
opt_state_block
)
...
@@ -481,7 +472,7 @@ class DistributeTranspiler:
...
@@ -481,7 +472,7 @@ class DistributeTranspiler:
inputs
=
{
'X'
:
recv_inputs
},
inputs
=
{
'X'
:
recv_inputs
},
outputs
=
{},
outputs
=
{},
attrs
=
{
attrs
=
{
"OptimizeBlock"
:
optimize_block
,
"OptimizeBlock"
:
pserver_program
.
block
(
1
)
,
"endpoint"
:
endpoint
,
"endpoint"
:
endpoint
,
"Fanin"
:
self
.
trainer_num
,
"Fanin"
:
self
.
trainer_num
,
"PrefetchBlock"
:
prefetch_block
"PrefetchBlock"
:
prefetch_block
...
...
python/paddle/fluid/framework.py
浏览文件 @
39f6274e
...
@@ -1107,6 +1107,10 @@ class Program(object):
...
@@ -1107,6 +1107,10 @@ class Program(object):
def
random_seed
(
self
):
def
random_seed
(
self
):
return
self
.
_seed
return
self
.
_seed
@
property
def
num_blocks
(
self
):
return
self
.
desc
.
num_blocks
()
@
random_seed
.
setter
@
random_seed
.
setter
def
random_seed
(
self
,
seed
):
def
random_seed
(
self
,
seed
):
if
not
isinstance
(
seed
,
int
):
if
not
isinstance
(
seed
,
int
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录