Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
5fa1f05c
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看板
提交
5fa1f05c
编写于
8月 20, 2018
作者:
T
tangwei12
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code clean and rename
上级
bf2f1599
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
22 deletion
+19
-22
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+1
-1
python/paddle/fluid/tests/unittests/test_dist_transpiler.py
python/paddle/fluid/tests/unittests/test_dist_transpiler.py
+8
-8
python/paddle/fluid/transpiler/distribute_transpiler.py
python/paddle/fluid/transpiler/distribute_transpiler.py
+10
-13
未找到文件。
python/paddle/fluid/framework.py
浏览文件 @
5fa1f05c
...
...
@@ -1366,7 +1366,7 @@ class Program(object):
# for distribute
self
.
_is_distributed
=
False
self
.
_is_chief
=
False
self
.
_slice_vars_and_atts
=
[]
self
.
_slice_vars_and_att
r
s
=
[]
self
.
_endpoints
=
[]
self
.
_distributed_lookup_table
=
None
...
...
python/paddle/fluid/tests/unittests/test_dist_transpiler.py
浏览文件 @
5fa1f05c
...
...
@@ -641,21 +641,21 @@ class TestLoadSliceVar(TranspilerTest):
pserver
,
_
=
self
.
get_pserver
(
self
.
pserver1_ep
)
pserver2
,
_
=
self
.
get_pserver
(
self
.
pserver2_ep
)
self
.
assertTrue
(
pserver
.
_slice_vars_and_atts
)
self
.
assertTrue
(
pserver2
.
_slice_vars_and_atts
)
self
.
assertTrue
(
pserver
.
_slice_vars_and_att
r
s
)
self
.
assertTrue
(
pserver2
.
_slice_vars_and_att
r
s
)
for
idx
in
xrange
(
len
(
pserver
.
_slice_vars_and_atts
)):
self
.
assertEqual
(
pserver
.
_slice_vars_and_atts
[
idx
][
0
],
pserver2
.
_slice_vars_and_atts
[
idx
][
0
])
for
idx
in
xrange
(
len
(
pserver
.
_slice_vars_and_att
r
s
)):
self
.
assertEqual
(
pserver
.
_slice_vars_and_att
r
s
[
idx
][
0
],
pserver2
.
_slice_vars_and_att
r
s
[
idx
][
0
])
total_numel
=
reduce
(
lambda
x
,
y
:
x
*
y
,
pserver
.
_slice_vars_and_atts
[
idx
][
0
].
shape
)
pserver
.
_slice_vars_and_att
r
s
[
idx
][
0
].
shape
)
self
.
assertEqual
(
total_numel
,
reduce
(
lambda
x
,
y
:
x
*
y
,
pserver
.
_slice_vars_and_atts
[
idx
][
2
].
shape
)
+
reduce
(
pserver
.
_slice_vars_and_att
r
s
[
idx
][
2
].
shape
)
+
reduce
(
lambda
x
,
y
:
x
*
y
,
pserver2
.
_slice_vars_and_atts
[
idx
][
2
].
shape
))
pserver2
.
_slice_vars_and_att
r
s
[
idx
][
2
].
shape
))
if
__name__
==
"__main__"
:
...
...
python/paddle/fluid/transpiler/distribute_transpiler.py
浏览文件 @
5fa1f05c
...
...
@@ -626,7 +626,7 @@ class DistributeTranspiler(object):
attrs
=
attrs
)
# add distributed attrs
pserver_program
.
_slice_vars_and_att
s
=
self
.
_get_slice_vars_and_att
s
(
pserver_program
.
_slice_vars_and_att
rs
=
self
.
_get_slice_vars_and_attr
s
(
endpoint
)
pserver_program
.
_sync_with_cpp
()
...
...
@@ -704,31 +704,28 @@ class DistributeTranspiler(object):
attrs
=
op
.
all_attrs
())
# add slice vars
s_prog
.
_slice_vars_and_att
s
=
self
.
_get_slice_vars_and_att
s
(
endpoint
)
s_prog
.
_slice_vars_and_att
rs
=
self
.
_get_slice_vars_and_attr
s
(
endpoint
)
return
s_prog
def
_get_slice_vars_and_atts
(
self
,
endpoint
):
slice_vars_and_atts
=
[]
block_suffix
=
"
.
block"
def
_get_slice_vars_and_att
r
s
(
self
,
endpoint
):
slice_vars_and_att
r
s
=
[]
block_suffix
=
"block"
for
param
in
self
.
param_grad_ep_mapping
[
endpoint
][
"params"
]:
suff_idx
=
param
.
name
.
find
(
block_suffix
)
if
suff_idx
<=
0
:
orig_var_name
,
block_name
,
_
=
self
.
_get_varname_parts
(
param
)
if
not
block_name
:
continue
orig_var_name
=
param
.
name
[:
suff_idx
]
block_idx
=
int
(
param
.
name
[
suff_idx
+
len
(
block_suffix
):])
block_idx
=
int
(
block_name
.
split
(
block_suffix
)[
1
])
orig_var
=
self
.
origin_program
.
global_block
().
vars
[
orig_var_name
]
skip_numel
=
0
slice_vars
=
self
.
param_var_mapping
[
orig_var_name
]
for
slice_var
in
slice_vars
[:
block_idx
]:
skip_numel
+=
reduce
(
lambda
x
,
y
:
x
*
y
,
slice_var
.
shape
)
slice_vars_and_atts
.
append
([
orig_var
,
skip_numel
,
param
])
slice_vars_and_att
r
s
.
append
([
orig_var
,
skip_numel
,
param
])
return
slice_vars_and_atts
return
slice_vars_and_att
r
s
# ====================== private transpiler functions =====================
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录