-
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
[phi] migrate where_op into phi #39811
Conversation
Thanks for your contribution! |
912bade
to
565cab7
Compare
f7676ab
to
2f7c1bd
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 for op benchmark
// auto config = backends::gpu::GetGpuLaunchConfig1D(ctx, numel); | ||
// WhereCUDAKernel< | ||
// T><<<config.block_per_grid.x, config.thread_per_block.x, 0, stream>>>( | ||
// numel, cond_data, x_data, y_data, out_data); |
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.
请删除L22 - L29、L37 - L48
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.
已删
// Cond | ||
template <typename T> | ||
struct CondFunctor { | ||
inline HOSTDEVICE T operator()(const bool cond, const T x, const T y) const { | ||
return cond ? x : y; | ||
} | ||
}; | ||
|
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.
elementwise_functor是放elementwise相关算子的functor,如果CondFunctor只有where_op的GPU Kernel使用,建议将其和实现放在一起,不用单独拿出来
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.
update
#include "paddle/phi/kernels/where_kernel.h" | ||
|
||
#include "paddle/phi/kernels/funcs/elementwise_functor.h" | ||
#include "paddle/phi/kernels/gpu/elementwise.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.
这里可以引用funcs下的broadcast_function.h,直接使用elementwise.h会引入更多多余的代码
paddle/phi/infermeta/multiary.cc
Outdated
PADDLE_ENFORCE_EQ( | ||
cond_dims, | ||
x_dims, | ||
paddle::platform::errors::InvalidArgument( |
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.
这里用phi:: 命名空间
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.
update
paddle/phi/infermeta/multiary.cc
Outdated
x_dims)); | ||
PADDLE_ENFORCE_EQ(x_dims, | ||
y_dims, | ||
paddle::platform::errors::InvalidArgument( |
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.
update
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
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
Others
PR changes
OPs
Describe
迁移where_op,以及修复PR39806comments