Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
7a633e64
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
未验证
提交
7a633e64
编写于
8月 29, 2023
作者:
X
xiaoguoguo626807
提交者:
GitHub
8月 29, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
【new ir】modify test comp divide_grad (#56697)
* modify test comp grad * modify test comp grad
上级
ad93dc0c
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
10 addition
and
20 deletion
+10
-20
python/paddle/autograd/backward.py
python/paddle/autograd/backward.py
+10
-20
未找到文件。
python/paddle/autograd/backward.py
浏览文件 @
7a633e64
...
...
@@ -179,51 +179,41 @@ def prune_ops(total_ops, inputs_set, outputs_set, no_grad_set):
pruned op in total_ops is uneffective_ops, else is effective_ops
'''
relevant_op_flags
=
[
True
]
*
len
(
total_ops
)
intersection_op_flags
=
[
True
]
*
len
(
total_ops
)
union_op_flags
=
[
False
]
*
len
(
total_ops
)
# from input to output
if
inputs_set
:
for
i
,
op
in
enumerate
(
total_ops
):
if
some_in_set
(
op
.
results
(),
inputs_set
):
union_op_flags
[
i
]
=
True
continue
if
some_in_set
(
op
.
operands_source
(),
inputs_set
):
union_op_flags
[
i
]
=
True
for
value
in
op
.
results
():
if
value
not
in
no_grad_set
:
inputs_set
.
add
(
value
)
else
:
relevant
_op_flags
[
i
]
=
False
intersection
_op_flags
[
i
]
=
False
# from output to input
for
i
,
op
in
reversed
(
list
(
enumerate
(
total_ops
))):
if
some_in_set
(
op
.
results
(),
outputs_set
):
union_op_flags
[
i
]
=
True
for
operand
in
op
.
operands_source
():
if
operand
not
in
no_grad_set
:
outputs_set
.
add
(
operand
)
else
:
relevant_op_flags
[
i
]
=
False
# recover full op or full_Intarray op created by mutable attribute.
total_ops_list
=
list
(
total_ops
)
for
i
,
op
in
enumerate
(
total_ops_list
):
if
relevant_op_flags
[
i
]
is
False
:
for
result
in
op
.
results
():
if
result
.
has_one_use
():
next_op
=
result
.
first_use
().
owner
()
if
(
next_op
in
total_ops
and
relevant_op_flags
[
total_ops_list
.
index
(
next_op
)]
is
True
):
relevant_op_flags
[
i
]
=
True
else
:
continue
union_op_flags
[
i
]
=
False
intersection_op_flags
[
i
]
=
False
effective_ops
=
[
total_ops
[
i
]
for
i
in
range
(
len
(
total_ops
))
if
relevant
_op_flags
[
i
]
total_ops
[
i
]
for
i
in
range
(
len
(
total_ops
))
if
intersection
_op_flags
[
i
]
]
uneffective_ops
=
[
total_ops
[
i
]
for
i
in
reversed
(
range
(
len
(
total_ops
)))
if
not
relevant
_op_flags
[
i
]
if
not
union
_op_flags
[
i
]
]
return
effective_ops
,
uneffective_ops
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录