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

Implement the composition of pow_grad #62336

Merged
merged 7 commits into from
Mar 21, 2024

Conversation

YibinLiu666
Copy link
Contributor

@YibinLiu666 YibinLiu666 commented Mar 3, 2024

PR types

Others

PR changes

Others

Description

实现pow的一阶微分组合,测试代码为:

import paddle
import numpy as np

def test_pow_grad():
    paddle.framework.core.set_prim_eager_enabled(False)
    shape = [1024, 512]
    x = paddle.to_tensor(np.random.randn(*shape), dtype="float32")
    x.stop_gradient=False
    y_fused_res = paddle.pow(x, 2.7)
    dx_fused_res = paddle.grad(y_fused_res, x, create_graph=True, retain_graph=False)[0]
    paddle.framework.core.set_prim_eager_enabled(True)
    y_composite_res = paddle.pow(x, 2.7)
    dx_composite_res = paddle.grad(y_composite_res, x, create_graph=True, retain_graph=False)[0]
    np.testing.assert_allclose(dx_fused_res.numpy(), dx_composite_res.numpy(), 1e-6, 1e-6)

@HydrogenSulfate

Copy link

paddle-bot bot commented Mar 3, 2024

你的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.

@paddle-bot paddle-bot bot added the contributor External developers label Mar 3, 2024
Copy link
Contributor

@HydrogenSulfate HydrogenSulfate left a comment

Choose a reason for hiding this comment

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

LGTM

@cyber-pioneer 麻烦卓哥也review一下

Copy link
Contributor

@Charles-hit Charles-hit left a comment

Choose a reason for hiding this comment

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

因为这个拆解规则是动静统一的,一阶拆解的话加一个静态图测试吧

@YibinLiu666
Copy link
Contributor Author

因为这个拆解规则是动静统一的,一阶拆解的话加一个静态图测试吧

已添加

Copy link

paddle-ci-bot bot commented Mar 17, 2024

Sorry to inform you that 3519a8e's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.


import sys

sys.path.append('../../../../legacy_test/')
Copy link
Contributor

Choose a reason for hiding this comment

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

这行删除

Copy link
Contributor

@heavyrain-lzy heavyrain-lzy left a comment

Choose a reason for hiding this comment

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

LGTM for YAML

@Charles-hit Charles-hit merged commit 55550bf into PaddlePaddle:develop Mar 21, 2024
29 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants