From ea1f4702c10efb8b2b5e8447c7af8e9a24c4bfec Mon Sep 17 00:00:00 2001 From: sprouteer <89541335+sprouteer@users.noreply.github.com> Date: Thu, 25 Aug 2022 11:22:43 +0800 Subject: [PATCH] Fix unique_kernel bugs (#45032) * fix unique_kernel bugs * fix unique kernel cu bugs --- paddle/phi/kernels/gpu/unique_kernel.cu | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/paddle/phi/kernels/gpu/unique_kernel.cu b/paddle/phi/kernels/gpu/unique_kernel.cu index 3d44c9af03c..9938d949c59 100644 --- a/paddle/phi/kernels/gpu/unique_kernel.cu +++ b/paddle/phi/kernels/gpu/unique_kernel.cu @@ -333,9 +333,11 @@ static void ComputeUniqueDims(const Context& context, // 3. counts: 'counts' counts->Resize(phi::make_ddim({num_out})); auto* count_data = context.template Alloc(counts); - thrust::fill(thrust::device, count_data, count_data + row, 0); - thrust::adjacent_difference( - thrust::device, range_data_ptr + 1, range_data_ptr + row + 1, count_data); + thrust::fill(thrust::device, count_data, count_data + num_out, 0); + thrust::adjacent_difference(thrust::device, + range_data_ptr + 1, + range_data_ptr + num_out + 1, + count_data); } // Calculate unique when 'axis' is set -- GitLab