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] migrate where_op into phi #39811

Merged
merged 1 commit into from
Mar 1, 2022
Merged

Conversation

ronny1996
Copy link
Contributor

@ronny1996 ronny1996 commented Feb 22, 2022

PR types

Others

PR changes

OPs

Describe

迁移where_op,以及修复PR39806comments

@ronny1996 ronny1996 changed the title [phi] migrate where into phi [phi] migrate where_op into phi Feb 22, 2022
@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@ronny1996 ronny1996 force-pushed the phi_where branch 3 times, most recently from 912bade to 565cab7 Compare February 23, 2022 07:32
@ronny1996 ronny1996 force-pushed the phi_where branch 2 times, most recently from f7676ab to 2f7c1bd Compare February 24, 2022 05:38
ZzSean
ZzSean previously approved these changes Feb 24, 2022
Copy link
Contributor

@ZzSean ZzSean left a 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请删除L22 - L29、L37 - L48

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已删

Comment on lines 95 to 102
// Cond
template <typename T>
struct CondFunctor {
inline HOSTDEVICE T operator()(const bool cond, const T x, const T y) const {
return cond ? x : y;
}
};

Copy link
Contributor

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使用,建议将其和实现放在一起,不用单独拿出来

Copy link
Contributor Author

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"
Copy link
Contributor

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_ENFORCE_EQ(
cond_dims,
x_dims,
paddle::platform::errors::InvalidArgument(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里用phi:: 命名空间

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update

x_dims));
PADDLE_ENFORCE_EQ(x_dims,
y_dims,
paddle::platform::errors::InvalidArgument(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update

Copy link
Contributor

@MingMingShangTian MingMingShangTian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ronny1996 ronny1996 merged commit 468a2a1 into PaddlePaddle:develop Mar 1, 2022
@ronny1996 ronny1996 deleted the phi_where branch March 1, 2022 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants