Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
c280b7be
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看板
未验证
提交
c280b7be
编写于
3月 12, 2020
作者:
C
Chengmo
提交者:
GitHub
3月 12, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test=develop, speed create clip program (#22950) (#22969)
speed create clip op
上级
99cf2e61
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
10 addition
and
6 deletion
+10
-6
python/paddle/fluid/clip.py
python/paddle/fluid/clip.py
+10
-6
未找到文件。
python/paddle/fluid/clip.py
浏览文件 @
c280b7be
...
@@ -523,28 +523,32 @@ def append_gradient_clip_ops(param_grads):
...
@@ -523,28 +523,32 @@ def append_gradient_clip_ops(param_grads):
clip_attr
.
_process_context
(
context
=
context
,
param
=
p
,
grad
=
g
)
clip_attr
.
_process_context
(
context
=
context
,
param
=
p
,
grad
=
g
)
res
=
[]
res
=
[]
param_new_grad_dict
=
dict
()
for
p
,
g
in
param_grads
:
for
p
,
g
in
param_grads
:
if
g
is
None
:
if
g
is
None
:
continue
continue
with
p
.
block
.
program
.
_optimized_guard
(
with
p
.
block
.
program
.
_optimized_guard
(
[
p
,
g
]),
framework
.
name_scope
(
'append_graident_clip_@CLIP'
):
[
p
,
g
]),
framework
.
name_scope
(
'append_graident_clip_@CLIP'
):
res
.
append
(
clip_attr
.
_create_operators
(
param
=
p
,
grad
=
g
))
param
,
new_grad
=
clip_attr
.
_create_operators
(
param
=
p
,
grad
=
g
)
param_new_grad_dict
[
param
.
name
]
=
new_grad
.
name
res
.
append
([
param
,
new_grad
])
# change wrong mapping relation between param & grad in clip op
# change wrong mapping relation between param & grad in clip op
clip_flag
=
'@CLIP'
clip_flag
=
'@CLIP'
block_id_list
=
[]
for
p
,
g
in
param_grads
:
for
p
,
g
in
param_grads
:
if
g
is
None
:
if
g
is
None
:
continue
continue
block_id
=
p
.
block
.
idx
if
block_id
in
block_id_list
:
continue
block_id_list
.
append
(
block_id
)
for
op
in
p
.
block
.
program
.
global_block
().
ops
:
for
op
in
p
.
block
.
program
.
global_block
().
ops
:
if
'op_namescope'
in
op
.
all_attrs
()
and
clip_flag
in
op
.
attr
(
if
'op_namescope'
in
op
.
all_attrs
()
and
clip_flag
in
op
.
attr
(
"op_namescope"
):
"op_namescope"
):
if
op
.
attr
(
'op_role_var'
):
if
op
.
attr
(
'op_role_var'
):
param_name
=
op
.
attr
(
'op_role_var'
)[
0
]
param_name
=
op
.
attr
(
'op_role_var'
)[
0
]
index
=
0
correct_p_g
=
[
param_name
,
param_new_grad_dict
[
param_name
]]
for
i
in
range
(
len
(
res
)):
if
res
[
i
][
0
].
name
==
param_name
:
index
=
i
correct_p_g
=
[
param_name
,
res
[
index
][
1
].
name
]
op
.
_set_attr
(
'op_role_var'
,
correct_p_g
)
op
.
_set_attr
(
'op_role_var'
,
correct_p_g
)
return
res
return
res
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录