Skip to content

Commit

Permalink
Fix fusedL2NN bug that can happen when the same point appears in both…
Browse files Browse the repository at this point in the history
… x and y (#1040)

Solves #1036 

Even when computing a sum of squares, the distance from a point to itself can apparently be `-0.0` in which case the square root is `nan` and comparisons are broken.

Authors:
  - Louis Sugy (https://github.com/Nyrio)

Approvers:
  - Ben Frederickson (https://github.com/benfred)
  - Corey J. Nolet (https://github.com/cjnolet)

URL: #1040
  • Loading branch information
Nyrio authored Nov 23, 2022
1 parent a6961dc commit c1b077e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cpp/include/raft/distance/detail/fused_l2_nn.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ __global__ __launch_bounds__(P::Nthreads, 2) void fusedL2NNkernel(OutT* min,
for (int i = 0; i < P::AccRowsPerTh; ++i) {
#pragma unroll
for (int j = 0; j < P::AccColsPerTh; ++j) {
acc[i][j] = raft::mySqrt(acc[i][j]);
auto acc_ij = acc[i][j];
acc[i][j] = acc_ij > DataT{0} ? raft::mySqrt(acc_ij) : DataT{0};
}
}
}
Expand Down

0 comments on commit c1b077e

Please sign in to comment.