Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
658387b0
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看板
未验证
提交
658387b0
编写于
11月 10, 2022
作者:
Z
zhaoyingli
提交者:
GitHub
11月 10, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[AutoParallel] fix insert concat op (#47710)
* fix insert concat op * fix fp16 assert
上级
d926c270
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
12 deletion
+45
-12
python/paddle/distributed/auto_parallel/dist_loader.py
python/paddle/distributed/auto_parallel/dist_loader.py
+1
-1
python/paddle/distributed/passes/auto_parallel_fp16.py
python/paddle/distributed/passes/auto_parallel_fp16.py
+44
-11
未找到文件。
python/paddle/distributed/auto_parallel/dist_loader.py
浏览文件 @
658387b0
...
...
@@ -134,7 +134,7 @@ class DistributedDataLoaderFromGenerator(DistributedDataLoaderBase):
raise
StopIteration
def
_infer_steps
(
self
):
if
self
.
steps_per_epoch
is
not
None
:
if
isinstance
(
self
.
steps_per_epoch
,
int
)
and
self
.
steps_per_epoch
>
1
:
return
self
.
steps_per_epoch
try
:
if
isinstance
(
self
.
dataset
,
IterableDataset
):
...
...
python/paddle/distributed/passes/auto_parallel_fp16.py
浏览文件 @
658387b0
...
...
@@ -487,9 +487,8 @@ class FP16State:
# create cast grad
grad_slot_name
=
slot_name
+
"@GRAD"
assert
(
grad_slot_name
in
op
.
output_names
),
"[{}], Current Op: {}"
.
format
(
grad_slot_name
,
str
(
op
))
if
grad_slot_name
not
in
op
.
output_names
:
continue
# some forward input maybe stop_gradient=True, e.g. input_mask
if
len
(
op
.
output
(
grad_slot_name
))
==
0
:
...
...
@@ -785,33 +784,67 @@ class FP16Pass(AMPPass):
with
main_program
.
_optimized_guard
([]):
block
=
main_program
.
global_block
()
all_infs
=
paddle
.
fluid
.
layers
.
concat
(
found_infs
)
# all_infs = paddle.fluid.layers.concat(found_infs)
all_infs
=
block
.
create_var
(
name
=
paddle
.
fluid
.
unique_name
.
generate_with_ignorable_key
(
"."
.
join
([
'concat'
,
'tmp'
])
),
dtype
=
found_infs
[
0
].
dtype
,
shape
=
None
,
lod_level
=
found_infs
[
0
].
lod_level
,
type
=
found_infs
[
0
].
type
,
persistable
=
False
,
stop_gradient
=
False
,
)
concat_op
=
block
.
append_op
(
type
=
'concat'
,
inputs
=
{
'X'
:
found_infs
},
outputs
=
{
'Out'
:
[
all_infs
]},
attrs
=
{
'axis'
:
0
},
)
set_var_dist_attr
(
self
.
dist_context
,
all_infs
,
[
-
1
],
world_process_group
.
ranks
,
)
new_op
=
block
.
ops
[
-
1
]
assert
new_op
.
type
==
"concat"
_set_op_dist_attr_with_ranks
(
new
_op
,
concat
_op
,
world_process_group
.
ranks
,
block
,
self
.
dist_context
,
)
found_inf
=
paddle
.
fluid
.
layers
.
reduce_any
(
all_infs
)
# found_inf = paddle.fluid.layers.reduce_any(all_infs)
found_inf
=
block
.
create_var
(
name
=
paddle
.
fluid
.
unique_name
.
generate_with_ignorable_key
(
"."
.
join
([
'reduce_any'
,
'tmp'
])
),
dtype
=
all_infs
.
dtype
,
shape
=
None
,
lod_level
=
all_infs
.
lod_level
,
type
=
all_infs
.
type
,
persistable
=
False
,
stop_gradient
=
False
,
)
reduce_any_op
=
block
.
append_op
(
type
=
'reduce_any'
,
inputs
=
{
'X'
:
all_infs
},
outputs
=
{
'Out'
:
found_inf
},
attrs
=
{
'dim'
:
[
0
],
'keep_dim'
:
False
,
'reduce_all'
:
True
,
},
)
set_var_dist_attr
(
self
.
dist_context
,
found_inf
,
[
-
1
],
world_process_group
.
ranks
,
)
new_op
=
block
.
ops
[
-
1
]
assert
new_op
.
type
==
"reduce_any"
_set_op_dist_attr_with_ranks
(
new
_op
,
reduce_any
_op
,
world_process_group
.
ranks
,
block
,
self
.
dist_context
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录