-
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
fix KthvalueInferMeta #62801
fix KthvalueInferMeta #62801
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
❌ The PR is not created using PR's template. You can refer to this Demo. |
这里确实存在infermeta的问题, 不过还有几个问题:
|
auto output_size = indices->numel();
auto u_size = sizeof(int64_t);
int64_t* out_data = new int64_t[output_size];
cudaMemcpy(out_data, indices->data(), u_size * output_size, cudaMemcpyDeviceToHost);
std::cout<<"kthvalue"<<std::endl;
for(int i = 0;i < output_size; i++){
std::cout<<out_data[i]<< " ";
}
std::cout<<std::endl; 因为可以看到在kernel里面他申请的类型就是 int64_t* indices_data = dev_ctx.template Alloc<int64_t>(indices); 在‘scale’的kernel里面加了下面的逻辑: template <typename T, typename Context>
void ScaleKernel(const Context& dev_ctx,
const DenseTensor& x,
const Scalar& scale,
float bias,
bool bias_after_scale,
DenseTensor* out) {
auto output_size = x.numel();
auto u_size = sizeof(T);
T* out_data = new T[output_size];
cudaMemcpy(out_data, x.data(), u_size * output_size, cudaMemcpyDeviceToHost);
std::cout<<"x"<<std::endl;
for(int i = 0;i < output_size; i++){
std::cout<<out_data[i]<< " ";
}
std::cout<<std::endl;
打印出的结果就是上面Pr Description里面的结果,其实也就是说明这里的
可以发现他的选择是正确的。
从 |
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
Others
Description
问题描述
下述动转静代码执行时
会遇到
indices
输出全为0的问题静态图如下:
将
kthvalue
算子中的Value(%2)和scale_
算子中的Value(%2)分别打印输出猜测是数据类型错误导致的。
在
paddle/phi/kernels/gpu/kthvalue_kernel.cu
中indices
的数据类型为定位到
InferMeta
的问题。