-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Implement the composition of cos_double_grad #62340
Implement the composition of cos_double_grad #62340
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
@@ -53,6 +53,29 @@ void tanh_double_grad(const Tensor& out, | |||
} | |||
} | |||
|
|||
template <typename T> | |||
void cos_double_grad(const Tensor& x, | |||
const paddle::optional<Tensor>& grad_out, |
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.
grad_out即dy会是optional吗?dy应该是一阶算子的一个输入,如果用户不在grad接口里指定dy,那dy默认会是全1矩阵而不会是空的吧
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.
void SinDoubleGradKernel(const Context& dev_ctx, |
x = paddle.to_tensor(primal, dtype='float32', stop_gradient=False) | ||
x.stop_gradient = False | ||
y = paddle.cos(x) | ||
x_cotangent = paddle.grad( |
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.
Done
x = paddle.to_tensor(primal, dtype='float32', stop_gradient=False) | ||
x.stop_gradient = False | ||
y = paddle.cos(x) | ||
x_cotangent = paddle.grad( |
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.
Done
import paddle | ||
from paddle.base import core | ||
|
||
sys.path.append('../../../../legacy_test/') |
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.
Done
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
… cos_double_grad rebase
c917b6f
PR types
Others
PR changes
Others
Description
实现pow的一阶微分组合,测试代码为:
@HydrogenSulfate