-
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
Tranpose layout #53351
Tranpose layout #53351
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
❌ The PR is not created using PR's template. You can refer to this Demo. |
2177228
to
63c4fe0
Compare
paddle/fluid/prim/api/api.yaml
Outdated
@@ -35,6 +35,7 @@ | |||
- scatter_nd_add | |||
- tile | |||
- transpose | |||
- trans_layout |
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.
这个要加在prim算子中吗?
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.
已经删除
output : Tensor(x_grad) | ||
infer_meta : | ||
func : TransLayoutGradInferMeta | ||
param : [x, out_grad, perm] |
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.
param和args参数相同的不用再配置param了
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.
已经修改
paddle/phi/infermeta/unary.cc
Outdated
void TransLayoutGradInferMeta(const MetaTensor& x, | ||
const MetaTensor& out_grad, | ||
const std::vector<int>& axis, | ||
MetaTensor* x_grad) { | ||
TransposeGradInferMeta(out_grad, axis, x_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.
这个放在backward.cc中吧,顺便的话帮忙把TransposeGradInferMeta
也搬一下,thx~
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.
已修改
paddle/phi/infermeta/unary.h
Outdated
@@ -624,6 +624,11 @@ void TransposeInferMeta(const MetaTensor& x, | |||
const std::vector<int>& axis, | |||
MetaTensor* out); | |||
|
|||
void TransLayoutGradInferMeta(const MetaTensor& x, |
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.
已修改
paddle/phi/infermeta/unary.cc
Outdated
const MetaTensor& out_grad, | ||
const std::vector<int>& axis, | ||
MetaTensor* x_grad) { | ||
TransposeGradInferMeta(out_grad, axis, x_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.
layout设置加在这里吧
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.
已修改
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(); |
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.
kernel里不用设置layout
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.
已修改
e347443
to
55d03ef
Compare
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. |
55d03ef
to
e347443
Compare
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
PR types
New features
PR changes
OPs
Description
Pcard-70459
新增一个transpose_layout算子,保证transpose_layout反向输出x_grad的layout与前向x的layout保持一致