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

Tranpose layout #53351

Merged
merged 10 commits into from
May 15, 2023
Merged

Conversation

AnnaTrainingG
Copy link
Contributor

@AnnaTrainingG AnnaTrainingG commented Apr 26, 2023

PR types

New features

PR changes

OPs

Description

Pcard-70459
新增一个transpose_layout算子,保证transpose_layout反向输出x_grad的layout与前向x的layout保持一致

@paddle-bot
Copy link

paddle-bot bot commented Apr 26, 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.

@paddle-bot
Copy link

paddle-bot bot commented Apr 26, 2023

❌ 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.

@@ -35,6 +35,7 @@
- scatter_nd_add
- tile
- transpose
- trans_layout
Copy link
Contributor

Choose a reason for hiding this comment

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

这个要加在prim算子中吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已经删除

output : Tensor(x_grad)
infer_meta :
func : TransLayoutGradInferMeta
param : [x, out_grad, perm]
Copy link
Contributor

Choose a reason for hiding this comment

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

param和args参数相同的不用再配置param了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已经修改

Comment on lines 4508 to 4489
void TransLayoutGradInferMeta(const MetaTensor& x,
const MetaTensor& out_grad,
const std::vector<int>& axis,
MetaTensor* x_grad) {
TransposeGradInferMeta(out_grad, axis, x_grad);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

这个放在backward.cc中吧,顺便的话帮忙把TransposeGradInferMeta也搬一下,thx~

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

@@ -624,6 +624,11 @@ void TransposeInferMeta(const MetaTensor& x,
const std::vector<int>& axis,
MetaTensor* out);

void TransLayoutGradInferMeta(const MetaTensor& x,
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 Author

Choose a reason for hiding this comment

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

已修改

const MetaTensor& out_grad,
const std::vector<int>& axis,
MetaTensor* x_grad) {
TransposeGradInferMeta(out_grad, axis, x_grad);
Copy link
Contributor

Choose a reason for hiding this comment

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

layout设置加在这里吧

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

const std::vector<int>& axis,
DenseTensor* x_grad) {
TransposeGradKernel<T, Context>(dev_ctx, out_grad, axis, x_grad);
phi::DenseTensorUtils::GetMutableMeta(x_grad)->layout = x.layout();
Copy link
Contributor

Choose a reason for hiding this comment

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

kernel里不用设置layout

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

@AnnaTrainingG AnnaTrainingG force-pushed the tranpose_layout branch 2 times, most recently from e347443 to 55d03ef Compare April 27, 2023 09:20
@paddle-ci-bot
Copy link

paddle-ci-bot bot commented May 5, 2023

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

Copy link
Contributor

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

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

LGTM

@wanghuancoder wanghuancoder merged commit 3dce9f0 into PaddlePaddle:develop May 15, 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.

3 participants