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

[PRIM][PIR]Support no grad in vjp #57294

Merged

Conversation

Charles-hit
Copy link
Contributor

PR types

New features

PR changes

Others

Description

Pcard-66975
support no grad in vjp.

@paddle-bot
Copy link

paddle-bot bot commented Sep 13, 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.

std::vector<std::vector<Tensor>> ConstructVjpResultByStopGradients(
const std::vector<std::vector<Tensor>>& outputs,
const std::vector<std::vector<bool>>& stop_gradients) {
SetOutputWithNoGrads(outputs, stop_gradients);
Copy link
Contributor

Choose a reason for hiding this comment

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

stop_gradients=true 和 no_grad语义不是一个意思吧,set_empty_type 是代表什么

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这儿应该是前向stop_gradient来表示创不创建反向变量,ir层面是一定会创建,这个函数名改成SetEmptyGrad吧,表示这个变量应该是空的,set_empty_type在ir中就是表示这个变量为空。

@@ -21,9 +21,34 @@ void set_output<LazyTensor>(const paddle::Tensor& x_tmp, paddle::Tensor* x) {
x->set_impl(x_tmp.impl());
}

/**
* @brief set output with no grads in new ir.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* @brief set output with no grads in new ir.
* @brief set output with no grads in pir.

/**
* @brief set output with no grads in new ir.
*
* In new ir, we use None type to express
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* In new ir, we use None type to express
* In pir, we use None type to express

@Charles-hit Charles-hit merged commit 5934505 into PaddlePaddle:develop Sep 14, 2023
27 checks passed
danleifeng pushed a commit to danleifeng/Paddle that referenced this pull request Nov 14, 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.

None yet

3 participants