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

[Macro] Increase macro constant MAX_RANK_SUPPORTED #63061

Conversation

HydrogenSulfate
Copy link
Contributor

@HydrogenSulfate HydrogenSulfate commented Mar 27, 2024

PR Category

Operator Mechanism

PR Types

Improvements

Description

prod_grad composite OP will fail when given input x.ndim>6, because prod_grad calls expand OP in its' implementation. So a fine solution is increasing MAX_RANK_SUPPORTED from 6 to 8.

after modification, 8D unitests can be passed successfully as below:

$ python test/legacy_test/test_reduce_op.py
image

import paddle

paddle.framework.core.set_prim_eager_enabled(True)

x = paddle.randn([1, 2, 1, 1, 2, 1, 1, 1])
x.stop_gradient = False
y = paddle.prod(x)

print(x)
g = paddle.grad(y, x)[0]
print(g)

'''
Tensor(shape=[1, 2, 1, 1, 1, 1, 1, 1], dtype=float32, place=Place(gpu:0), stop_gradient=False,
       [[[[[[[[0.04061465]]]]]],





         [[[[[[0.18230575]]]]]]]])
Tensor(shape=[1, 2, 1, 1, 1, 1, 1, 1], dtype=float32, place=Place(gpu:0), stop_gradient=True,
       [[[[[[[[0.18230575]]]]]],





         [[[[[[0.04061465]]]]]]]])
'''

Copy link

paddle-bot bot commented Mar 27, 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.

Copy link

paddle-bot bot commented Mar 27, 2024

❌ The PR is not created using PR's template. You can refer to this Demo.
Please use PR's template, it helps save our maintainers' time so that more developers get helped.

Copy link
Contributor

@zyfncg zyfncg left a comment

Choose a reason for hiding this comment

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

LGTM

@HydrogenSulfate HydrogenSulfate merged commit 2f3d469 into PaddlePaddle:develop Apr 1, 2024
30 checks passed
@HydrogenSulfate HydrogenSulfate deleted the increase_MAX_RANK_SUPPORTED branch April 1, 2024 07:21
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