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

[PIR+CINN]Support all modules of PIR+CINN with Python unittest #58641

Merged
merged 8 commits into from Nov 4, 2023

Conversation

Aurelius84
Copy link
Contributor

@Aurelius84 Aurelius84 commented Nov 3, 2023

PR types

New features

PR changes

Others

Description

Pcard-67164

支持了子图 「exp+sub」 的端到端 PIR+CINN 执行。

调试命令:FLAG_logbuflevel=-1 FLAGS_print_ir=1 FLAGS_call_stack_level=2 GLOG_v=6 FLAGS_enable_pir_api=1 python test_cinn_sub_graph.py > err.log 2>&1

image

Step 1: Python 端原生 Program

ForwardProgram is :
{
 (%0) = "pd_op.data" () {dtype:(pd_op.DataType)float32,name:"_jst.0.x.0",place:(pd_op.Place)Place(undefined:0),shape:(pd_op.IntArray)[64,128],stop_gradient:[false]} : () -> pd_op.tensor<64x128xf32>
 (%1) = "pd_op.exp" (%0) {stop_gradient:[false]} : (pd_op.tensor<64x128xf32>) -> pd_op.tensor<64x128xf32>
 (%2) = "pd_op.subtract" (%1, %0) {stop_gradient:[false]} : (pd_op.tensor<64x128xf32>, pd_op.tensor<64x128xf32>) -> pd_op.tensor<64x128xf32>
 () = "builtin.set_parameter" (%2) {parameter_name:"output_0"} : (pd_op.tensor<64x128xf32>) -> 
}

Step 2: After CINN related Pass

{
 (%0) = "pd_op.data" () {dtype:(pd_op.DataType)float32,name:"_jst.0.x.0",place:(pd_op.Place)Place(undefined:0),shape:(pd_op.IntArray)[64,128],stop_gradient:[false]} : () -> pd_op.tensor<64x128xf32>
 (%1) = "cinn_runtime.jit_kernel" (%0) {jit_info:(0x46aa1f90)} : (pd_op.tensor<64x128xf32>) -> pd_op.tensor<64x128xf32>
 () = "builtin.set_parameter" (%1) {parameter_name:"output_0"} : (pd_op.tensor<64x128xf32>) -> 
}

Step 3: After Lowering and ToKernelPass

{
 (%0) = "data(phi_kernel)" () {dtype:(pd_op.DataType)float32,kernel_key:<backend:Undefined|layout:Undefined(AnyLayout)|dtype:float32>,kernel_name:"data",name:"_jst.0.x.0",op_name:"pd_op.data",place:(pd_op.Place)Place(undefined:0),shape:(pd_op.IntArray)[64,128],stop_gradient:[false]} : () -> undefined_tensor<64x128xf32>
 (%1) = "shadow_feed(phi_kernel)" (%0) {kernel_key:<backend:GPU|layout:Undefined(AnyLayout)|dtype:float32>,kernel_name:"shadow_feed",op_name:"pd_op.shadow_feed"} : (undefined_tensor<64x128xf32>) -> gpu_tensor<64x128xf32>
 (%2) = "cinn_runtime.jit_kernel" (%1) {jit_info:(0x46aa1f90)} : (gpu_tensor<64x128xf32>) -> gpu_tensor<64x128xf32>
 () = "(phi_kernel)" (%2) {kernel_key:<backend:GPUDNN|layout:Undefined(AnyLayout)|dtype:float32>,kernel_name:"",op_name:"builtin.set_parameter",parameter_name:"output_0"} : (gpu_tensor<64x128xf32>) -> 
}

Copy link

paddle-bot bot commented Nov 3, 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.

#define REGISTER_IR_PASS(pass_type, pass_class) \
STATIC_ASSERT_PASS_GLOBAL_NAMESPACE( \
__reg_pir_pass__##pass_type, \
"REGISTER_IR_PASS must be called in global namespace"); \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里统一对global namespace 的全局static 变量命名加上 pir 前缀,避免libpaddle.so 与 libpir.so 中同名pass导致符号变量仅初始化一次,引起运行时另一个同名Pass未注册的错误。

Copy link
Contributor

@6clc 6clc left a comment

Choose a reason for hiding this comment

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

LGTM of cmake

lanxianghit
lanxianghit previously approved these changes Nov 3, 2023
zyfncg
zyfncg previously approved these changes Nov 3, 2023
test/cinn/pir/test_cinn_sub_graph.py Outdated Show resolved Hide resolved
@Aurelius84 Aurelius84 dismissed stale reviews from zyfncg and lanxianghit via ee269c0 November 4, 2023 10:52
@Aurelius84 Aurelius84 merged commit 352d48d into PaddlePaddle:develop Nov 4, 2023
28 checks passed
zeroRains pushed a commit to zeroRains/Paddle that referenced this pull request Nov 8, 2023
…ePaddle#58641)

* [PIR+CINN]Support all modules of PIR+CINN with Python unittest

* fix conflict

* fix conflict

* add subtract white list

* move unittest dir

* modify USE_PASS into USE_PIR_PASS to avoid symbolic conflict

* PR-CI-CINN require Python3.10 not Python3.9
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
…ePaddle#58641)

* [PIR+CINN]Support all modules of PIR+CINN with Python unittest

* fix conflict

* fix conflict

* add subtract white list

* move unittest dir

* modify USE_PASS into USE_PIR_PASS to avoid symbolic conflict

* PR-CI-CINN require Python3.10 not Python3.9
SecretXV pushed a commit to SecretXV/Paddle that referenced this pull request Nov 28, 2023
…ePaddle#58641)

* [PIR+CINN]Support all modules of PIR+CINN with Python unittest

* fix conflict

* fix conflict

* add subtract white list

* move unittest dir

* modify USE_PASS into USE_PIR_PASS to avoid symbolic conflict

* PR-CI-CINN require Python3.10 not Python3.9
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.

None yet

4 participants