-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[0-size Tensor No.12] Add 0-size Tensor support for as_real API. #73742
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
Conversation
|
你的PR提交成功,感谢你对开源项目的贡献! |
| if (out && out->numel() == 0) { | ||
| if (x.dtype() == DataType::COMPLEX64) { | ||
| out->set_type(DataType::FLOAT32); | ||
| } else if (x.dtype() == DataType::COMPLEX128) { | ||
| out->set_type(DataType::FLOAT64); | ||
| } else { | ||
| PADDLE_THROW(common::errors::Unimplemented( | ||
| "as_real is not supported data type (%s).", | ||
| DataTypeToString(x.dtype()))); | ||
| } | ||
| out->set_offset(x.offset()); | ||
| out->ResetHolder(x.Holder()); | ||
| out->ShareInplaceVersionCounterWith(x); | ||
| return; | ||
| } |
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.
修复似乎没有必要。as_real 应该已经被修过了,请修复之前先运行下paddleapitest 尝试能否复现问题,然后进行修复。如果复现不了问题需要添加几个0-size的单测
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/kernels/stride/as_complex_kernel.cc中的AsComplexStridedKernel函数
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.
可以添加几个单测,完善0-size Tensor的验证机制
|
Sorry to inform you that 6a725bd's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
|
close due to the following PR is merged: |
PR Category
Operator Mechanism
PR Types
Bug fixes
Description
修复:
a. 在Paddle代码中检索def as_real,发现as_real的核心实现调用的是_C_ops的as_real
b. 以_C_ops的as_real在paddle/phi/ops/yaml中检索,发现as_real的InferMeta函数使用为:AsRealInferMeta
c. 在代码中检索AsRealInferMeta,其函数体位于paddle\phi\infermeta\unary.cc,检查其对于0-size张量发现并无直接的相关操作
d. 在paddle/phi/kernels中检索as_real(asreal),寻找有关Kernel的相关实现。发现存在函数AsRealStridedKernel,添加对于0-size问题的判定
PaddleAPITest测试结果:

pcard-67164