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

[phi] add register of asreal #51313

Merged
merged 2 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ static std::set<std::string> OpsNeedSetOutputDtypeWhenRegisterPhiKernel = {
"angle",
"any_raw",
"arg_sort",
"as_real",
"atan2",
"auc",
"bincount",
Expand Down
1 change: 1 addition & 0 deletions paddle/phi/infermeta/unary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ void AsRealInferMeta(const MetaTensor& input, MetaTensor* output) {
auto out_dims = phi::make_ddim(out_dims_v);
output->set_dims(out_dims);
output->share_lod(input);
output->set_dtype(dtype::ToReal(input.dtype()));
}

void AsComplexInferMeta(const MetaTensor& input, MetaTensor* output) {
Expand Down
4 changes: 3 additions & 1 deletion paddle/phi/kernels/cpu/as_real_kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ using complex64 = ::phi::dtype::complex<float>;
using complex128 = ::phi::dtype::complex<double>;

PD_REGISTER_KERNEL(
as_real, CPU, ALL_LAYOUT, phi::AsRealKernel, complex64, complex128) {}
as_real, CPU, ALL_LAYOUT, phi::AsRealKernel, complex64, complex128) {
kernel->OutputAt(0).SetDataType(paddle::experimental::DataType::UNDEFINED);
}
4 changes: 3 additions & 1 deletion paddle/phi/kernels/gpu/as_real_kernel.cu
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ using complex64 = ::phi::dtype::complex<float>;
using complex128 = ::phi::dtype::complex<double>;

PD_REGISTER_KERNEL(
as_real, GPU, ALL_LAYOUT, phi::AsRealKernel, complex64, complex128) {}
as_real, GPU, ALL_LAYOUT, phi::AsRealKernel, complex64, complex128) {
kernel->OutputAt(0).SetDataType(paddle::experimental::DataType::UNDEFINED);
}