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] add an api to get param map when translating #58044

Merged
merged 5 commits into from
Oct 13, 2023

Conversation

kangguangli
Copy link
Contributor

@kangguangli kangguangli commented Oct 12, 2023

PR types

Others

PR changes

Others

Description

For program below,

# tests.py
import paddle
from paddle import pir
paddle.enable_static()

x = paddle.randn([4, 4])
main_program, start_program = (
    paddle.static.Program(),
    paddle.static.Program(),
)
with paddle.static.program_guard(main_program, start_program):
    x_s = paddle.static.data('x', [4, 4], x.dtype)
    x_s.stop_gradient = False
    y_s = paddle.matmul(x_s, x_s)
    z_s = paddle.add(y_s, y_s)
    k_s = paddle.tanh(z_s)
newir_program, mappings = pir.translate_to_new_ir_with_param_map(main_program.desc)

print(newir_program)
print(mappings)

Run FLAGS_enable_new_ir_in_executor=1 python test.py, we get

{
 (%0) = "pd_op.data" () {dtype:(pd_op.DataType)float32,is_persisable:[false],name:"x",place:(pd_op.Place)Place(undefined:0),shape:(pd_op.IntArray)[4,4],stop_gradient:[false]} : () -> pd_op.tensor<4x4xf32>
 (%1) = "pd_op.matmul" (%0, %0) {is_persisable:[false],stop_gradient:[false],transpose_x:false,transpose_y:false} : (pd_op.tensor<4x4xf32>, pd_op.tensor<4x4xf32>) -> pd_op.tensor<4x4xf32>
 (%2) = "pd_op.add" (%1, %1) {is_persisable:[false],stop_gradient:[false]} : (pd_op.tensor<4x4xf32>, pd_op.tensor<4x4xf32>) -> pd_op.tensor<4x4xf32>
 (%3) = "pd_op.tanh" (%2) {is_persisable:[false],stop_gradient:[false]} : (pd_op.tensor<4x4xf32>) -> pd_op.tensor<4x4xf32>
}

{'x': [Value(define_op_name=pd_op.data, index=0, dtype=pd_op.tensor<4x4xf32>)], 'matmul_v2_0.tmp_0': [Value(define_op_name=pd_op.matmul, index=0, dtype=pd_op.tensor<4x4xf32>)], 'elementwise_add_0': [Value(define_op_name=pd_op.add, index=0, dtype=pd_op.tensor<4x4xf32>)], 'tanh_0.tmp_0': [Value(define_op_name=pd_op.tanh, index=0, dtype=pd_op.tensor<4x4xf32>)]}

Others

Pcard-67164

@paddle-bot
Copy link

paddle-bot bot commented Oct 12, 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.

@kangguangli kangguangli merged commit e638c66 into PaddlePaddle:develop Oct 13, 2023
@kangguangli kangguangli deleted the bind_param_map branch October 13, 2023 11:22
Frida-a pushed a commit to Frida-a/Paddle that referenced this pull request Oct 14, 2023
* add an api to get param map when translating

* fix

* fix

* resolve conflicts
jiahy0825 pushed a commit to jiahy0825/Paddle that referenced this pull request Oct 16, 2023
* add an api to get param map when translating

* fix

* fix

* resolve conflicts
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 2023
* add an api to get param map when translating

* fix

* fix

* resolve conflicts
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.

2 participants