Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
e166873b
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e166873b
编写于
3月 03, 2021
作者:
S
sandyhouse
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
a97b9df0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
53 addition
and
14 deletion
+53
-14
python/paddle/fluid/optimizer.py
python/paddle/fluid/optimizer.py
+53
-14
未找到文件。
python/paddle/fluid/optimizer.py
浏览文件 @
e166873b
...
@@ -4046,7 +4046,7 @@ class PipelineOptimizer(object):
...
@@ -4046,7 +4046,7 @@ class PipelineOptimizer(object):
"""
"""
prev_op
=
[]
prev_op
=
[]
for
op
in
ops
:
for
op
in
ops
:
if
op
.
type
==
'send_v2'
or
op
.
type
==
'recv_v2'
:
if
op
.
type
==
'send_v2'
or
op
.
type
==
'recv_v2'
or
op
.
type
==
'c_broadcast'
:
continue
continue
if
op
==
cur_op
:
if
op
==
cur_op
:
break
break
...
@@ -4434,6 +4434,39 @@ class PipelineOptimizer(object):
...
@@ -4434,6 +4434,39 @@ class PipelineOptimizer(object):
ring_id
=
self
.
ring_id
+
2
+
prev_device_index
-
cur_device_index
-
1
ring_id
=
self
.
ring_id
+
2
+
prev_device_index
-
cur_device_index
-
1
if
pair
not
in
self
.
_pipeline_pair
:
if
pair
not
in
self
.
_pipeline_pair
:
self
.
_pipeline_pair
.
append
(
pair
)
self
.
_pipeline_pair
.
append
(
pair
)
if
self
.
schedule_mode
==
0
:
# GPipe
block
.
_insert_op
(
index
=
index
+
extra_index
,
type
=
'send_v2'
,
inputs
=
{
'X'
:
var
},
attrs
=
{
self
.
_op_device_key
:
prev_device
,
self
.
_op_role_key
:
op_role
,
'use_calc_stream'
:
True
,
'peer'
:
cur_device_index
,
'ring_id'
:
self
.
ring_id
if
cur_device_index
>
prev_device_index
else
self
.
ring_id
+
2
,
})
extra_index
+=
1
block
.
_insert_op
(
index
=
index
+
extra_index
,
type
=
'recv_v2'
,
outputs
=
{
'Out'
:
[
var
]},
attrs
=
{
'out_shape'
:
var
.
shape
,
'dtype'
:
var
.
dtype
,
self
.
_op_device_key
:
cur_device
,
self
.
_op_role_key
:
op_role
,
'use_calc_stream'
:
True
,
'peer'
:
prev_device_index
,
'ring_id'
:
self
.
ring_id
if
cur_device_index
>
prev_device_index
else
self
.
ring_id
+
2
,
})
extra_index
+=
1
continue
assert
self
.
schedule_mode
==
1
block
.
_insert_op
(
block
.
_insert_op
(
index
=
index
+
extra_index
,
index
=
index
+
extra_index
,
#type='send_v2',
#type='send_v2',
...
@@ -4452,19 +4485,19 @@ class PipelineOptimizer(object):
...
@@ -4452,19 +4485,19 @@ class PipelineOptimizer(object):
'root'
:
0
,
'root'
:
0
,
})
})
extra_index
+=
1
extra_index
+=
1
block
.
_insert_op
(
#
block._insert_op(
index
=
index
+
extra_index
,
#
index=index + extra_index,
type
=
'c_sync_comm_stream'
,
#
type='c_sync_comm_stream',
inputs
=
{
'X'
:
[
var
]},
#
inputs={'X': [var]},
outputs
=
{
'Out'
:
[
var
]},
#
outputs={'Out': [var]},
attrs
=
{
#
attrs={
self
.
_op_device_key
:
cur_device
,
#
self._op_device_key: cur_device,
self
.
_op_role_key
:
#
self._op_role_key:
core
.
op_proto_and_checker_maker
.
OpRole
.
Backward
,
#
core.op_proto_and_checker_maker.OpRole.Backward,
'ring_id'
:
self
.
ring_id
,
#
'ring_id': self.ring_id,
#'ring_id': self.ring_id if prev_device_index > cur_device_index else self.ring_id + 2,
#
#'ring_id': self.ring_id if prev_device_index > cur_device_index else self.ring_id + 2,
})
#
})
extra_index
+=
1
#
extra_index += 1
fill_shape
=
list
(
var
.
shape
)
fill_shape
=
list
(
var
.
shape
)
fill_shape
[
0
]
=
1
fill_shape
[
0
]
=
1
block
.
_insert_op
(
block
.
_insert_op
(
...
@@ -4509,6 +4542,7 @@ class PipelineOptimizer(object):
...
@@ -4509,6 +4542,7 @@ class PipelineOptimizer(object):
outputs
=
{
'Out'
:
[
var
]},
outputs
=
{
'Out'
:
[
var
]},
attrs
=
{
attrs
=
{
self
.
_op_device_key
:
cur_device
,
self
.
_op_device_key
:
cur_device
,
#self._op_role_key: core.op_proto_and_checker_maker.OpRole.Backward,
self
.
_op_role_key
:
op_role
,
self
.
_op_role_key
:
op_role
,
'ring_id'
:
self
.
ring_id
,
'ring_id'
:
self
.
ring_id
,
#'ring_id': self.ring_id if prev_device_index > cur_device_index else self.ring_id + 2,
#'ring_id': self.ring_id if prev_device_index > cur_device_index else self.ring_id + 2,
...
@@ -4987,6 +5021,10 @@ class PipelineOptimizer(object):
...
@@ -4987,6 +5021,10 @@ class PipelineOptimizer(object):
and
'local_rank'
in
main_block
.
program
.
_pipeline_opt
,
\
and
'local_rank'
in
main_block
.
program
.
_pipeline_opt
,
\
'Please use pipeline with fleet.'
'Please use pipeline with fleet.'
local_rank
=
main_block
.
program
.
_pipeline_opt
[
'local_rank'
]
local_rank
=
main_block
.
program
.
_pipeline_opt
[
'local_rank'
]
schedule_mode
=
0
if
'schedule_mode'
in
main_block
.
program
.
_pipeline_opt
:
schedule_mode
=
main_block
.
program
.
_pipeline_opt
[
'schedule_mode'
]
self
.
schedule_mode
=
schedule_mode
self
.
use_sharding
=
False
self
.
use_sharding
=
False
if
'use_sharding'
in
main_block
.
program
.
_pipeline_opt
:
if
'use_sharding'
in
main_block
.
program
.
_pipeline_opt
:
...
@@ -5074,6 +5112,7 @@ class PipelineOptimizer(object):
...
@@ -5074,6 +5112,7 @@ class PipelineOptimizer(object):
"inner_parallelism"
:
len
(
device_list
),
"inner_parallelism"
:
len
(
device_list
),
"num_pipeline_stages"
:
len
(
device_list
),
"num_pipeline_stages"
:
len
(
device_list
),
"pipeline_stage"
:
local_rank
,
"pipeline_stage"
:
local_rank
,
"schedule_mode"
:
schedule_mode
,
"section_program"
:
program_list
[
local_rank
],
"section_program"
:
program_list
[
local_rank
],
"place"
:
place_list
[
local_rank
],
"place"
:
place_list
[
local_rank
],
"place_id"
:
place_id
,
"place_id"
:
place_id
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录