-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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】modify Call vjp interface for controlflow grad #58277
【pir】modify Call vjp interface for controlflow grad #58277
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -43,7 +43,13 @@ def test_tanh_vjp1(self): | |||
out_grads = [[fill_constant_op.result(0)]] | |||
stop_gradients = [[False]] | |||
with paddle.pir.core.program_guard(newir_program): | |||
grad_outs = call_vjp(tanh_op, out_grads, stop_gradients) | |||
grad_outs = call_vjp( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
call_vjp 后续会提供两种形态的API么,一种是对于非控制流,可以不显式地指定inputs和outputs,这样使用起来更方便;也有一种是需要指定inputs和outputs的,扩展支持控制流的?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
前者的函数实现里是调用后者。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
目前是对非控制流op call_vjp改造;这些op在控制流block中需要修改call_vjp的输入. 控制流的op调用反向的接口使用其他接口,只负责返回反向空op, 复用ir_backward 逻辑填加其他op的反向op
* tmp * [PIR]Migrate maximum into pir * Polish code * add ir_grad of static_gradient * add test * modify bug * modify * add mean fill_constant test * modify cpu int32 test * get_shape_tensor * delete * add default place * modify grad * modify call_vjp * Update python/paddle/autograd/ir_backward.py * fix name * new ci --------- Co-authored-by: 0x45f <wangzhen45@baidu.com>
* tmp * [PIR]Migrate maximum into pir * Polish code * add ir_grad of static_gradient * add test * modify bug * modify * add mean fill_constant test * modify cpu int32 test * get_shape_tensor * delete * add default place * modify grad * modify call_vjp * Update python/paddle/autograd/ir_backward.py * fix name * new ci --------- Co-authored-by: 0x45f <wangzhen45@baidu.com>
* tmp * [PIR]Migrate maximum into pir * Polish code * add ir_grad of static_gradient * add test * modify bug * modify * add mean fill_constant test * modify cpu int32 test * get_shape_tensor * delete * add default place * modify grad * modify call_vjp * Update python/paddle/autograd/ir_backward.py * fix name * new ci --------- Co-authored-by: 0x45f <wangzhen45@baidu.com>
PR types
others
PR changes
others
Description
pcard-67164
修改call_vjp增加前向输入输出参数,控制流反向子block无法访问前向block中的输入输出变量,需要访问copy变量,因此在ir_backward中提供