Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add check ops for prim #52302

Merged
merged 9 commits into from
May 15, 2023

Conversation

Charles-hit
Copy link
Contributor

@Charles-hit Charles-hit commented Mar 29, 2023

PR types

New features

PR changes

Others

Description

Pcard-66975
PR改动在OPTest测试框架中为组合算子测试新增program检查功能,若该算子被组合算子拆解,那么就不应该出现该算子以及他自身的反向算子。

@paddle-bot
Copy link

paddle-bot bot commented Mar 29, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-ci-bot
Copy link

paddle-ci-bot bot commented May 2, 2023

Sorry to inform you that b590561's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@@ -675,6 +681,17 @@ def check_jit_comp(self):
)
net = PrimNet(self.public_python_api)
net = apply_to_static(net, False)
# ensure the operator not in program if check_prim is True
if self.prim_op_type == "comp" and self.op_type != "fill_any_like":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why "self.op_type != "fill_any_like"" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

动转静会在前向转静态图的时候把反向图也给构建了,fill_any_like的反向还是fill_any_like,所以把这个算子给过滤了。

Copy link
Contributor

@xiaoguoguo626807 xiaoguoguo626807 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.如果只拆解了反向 self.prim_op_type = prim ,是否需要判断program中不出现xxx_grad

Copy link
Contributor

@xiaoguoguo626807 xiaoguoguo626807 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.如果只拆解了反向 self.prim_op_type = prim ,是否需要判断program中不出现xxx_grad
2.最好加单测确定此检查已生效

@Charles-hit
Copy link
Contributor Author

Charles-hit commented May 9, 2023

1.算子反向检查在grad_checker中,无用的判断已经删除。
2.这个改动对所有组合算子的单测都会生效,若没有拆解单测会挂掉。

for op in net.forward.get_concrete_program(args)[1]
._train_program.block(0)
.ops
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use net.forward.get_concrete_program(args)[1].forward_program to avoid 'fill_any_like' condition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

backward_op_type = self.op_type + "_grad"
assert backward_op_type not in ops, (
"%s shouldn't appear in program when check_prim is True"
) % (backward_op_type)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this can cover the scene of CustomVJP?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不能,CustomVJP只能在动转静测试中触发

Copy link
Contributor

@Aurelius84 Aurelius84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for ignore cinn-ci task

@Charles-hit Charles-hit merged commit 3d6bd6a into PaddlePaddle:develop May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants