-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Move real and imag op to phi #39777
Move real and imag op to phi #39777
Conversation
✅ This PR's description meets the template requirements! |
Thanks for your contribution! |
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.
real和imag这两个kernel可以都放到complex_kernel文件里,能减少一些文件数量
|
||
#include "paddle/phi/common/complex.h" | ||
#include "paddle/phi/core/kernel_registry.h" | ||
#include "paddle/phi/kernels/imag_kernel.h" |
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.
imag_kernel.h
这个头文件能放在第一个吗?
#include "paddle/phi/common/complex.h" | ||
#include "paddle/phi/core/kernel_registry.h" | ||
#include "paddle/phi/kernels/impl/real_grad_kernel_impl.h" | ||
#include "paddle/phi/kernels/real_grad_kernel.h" |
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.
同上
#include "paddle/phi/common/complex.h" | ||
#include "paddle/phi/core/kernel_registry.h" | ||
#include "paddle/phi/kernels/impl/real_kernel_impl.h" | ||
#include "paddle/phi/kernels/real_kernel.h" |
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.
同上
|
||
#include "paddle/fluid/platform/for_range.h" | ||
#include "paddle/phi/kernels/funcs/complex_functors.h" | ||
#include "paddle/phi/kernels/imag_grad_kernel.h" |
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.
这里应该不需要引imag_grad_kernel.h
这个头文件了
|
||
#include "paddle/fluid/platform/for_range.h" | ||
#include "paddle/phi/kernels/funcs/complex_functors.h" | ||
#include "paddle/phi/kernels/imag_kernel.h" |
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.
同上
|
||
namespace phi { | ||
|
||
template <typename T, typename DeviceContext> |
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模板参数DeviceContext
先统一为Context
auto numel = x.numel(); | ||
auto* x_data = x.data<T>(); | ||
auto* out_data = dev_ctx.template Alloc<phi::funcs::Real<T>>( | ||
out, static_cast<size_t>(numel * sizeof(phi::funcs::Real<T>))); |
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.
这里需要明确指定out_data的内存大小吗?如果使用默认值分配会有问题吗?
done |
… move-real-and-imag-op-to-phi
@@ -0,0 +1,31 @@ | |||
/* Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved. |
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.
2021->2022
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.
在下个PR里修改
@@ -50,4 +50,14 @@ DenseTensor Conj(const Context& dev_ctx, const DenseTensor& x) { | |||
return x; | |||
} | |||
|
|||
template <typename T, typename DeviceContext> |
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.
DeviceContext -> Context
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.
在下个PR里修改
PR types
Function optimization
PR changes
OPs
Describe
Move real and imag op to phi