-
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]Move topk kernel to phi #40064
[Phi]Move topk kernel to phi #40064
Conversation
Thanks for your contribution! |
paddle/phi/kernels/funcs/transpose.h
Outdated
@@ -0,0 +1,61 @@ | |||
// Copyright (c) 2022 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.
这里能否试下直接用transpose_kernel.h中的Transpose,phi已经有两套transpose的封装了
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.
done, thx
paddle/phi/kernels/top_k_kernel.h
Outdated
template <typename T, typename Context> | ||
void TopkKernel(const Context& dev_ctx, | ||
const DenseTensor& x, | ||
paddle::optional<const DenseTensor&> k_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.
这种需要使用Scalar,而不是保留两个参数,麻烦参考scale kernel的scale参数修改一下
paddle/phi/ops/compat/top_k_sig.cc
Outdated
namespace phi { | ||
|
||
KernelSignature TopkOpArgumentMapping(const ArgumentMappingContext& ctx) { | ||
return KernelSignature("top_k", |
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.
同上,可以参考scale_sig
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.
done, thx
@@ -51,6 +51,19 @@ namespace operators { | |||
|
|||
using Tensor = framework::Tensor; | |||
|
|||
inline void GetDims(const phi::DDim& dim, int axis, int* pre, int* n, |
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的funcs下,虽然代码量较大,但迁移难度应该不大
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再改吧
paddle/phi/kernels/funcs/transpose.h
Outdated
namespace funcs { | ||
|
||
template <typename Context, typename T> | ||
inline void TransCompute(const int dim, |
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.
这里的TransCompute如果有复用的话可以和现有的Transpose整合一下,如果仅topk kernel使用的话可以放到topk 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.
done, thx
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 ci
PR types
Others
PR changes
OPs
Describe
Move topk kernel to phi