File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -633,6 +633,9 @@ __launch_bounds__(BLOCK_SIZE)
633633 s_distances[i] = l2_norms[new_neighbors[i % SKEWED_MAX_NUM_BI_SAMPLES]] +
634634 l2_norms[new_neighbors[i / SKEWED_MAX_NUM_BI_SAMPLES]] -
635635 2.0 * s_distances[i];
636+ // for fp32 vs fp16 precision differences resulting in negative distances when distance
637+ // should be 0 related issue: https://github.com/rapidsai/cuvs/issues/991
638+ s_distances[i] = s_distances[i] < 0 .0f ? 0 .0f : s_distances[i];
636639 }
637640 } else {
638641 s_distances[i] = std::numeric_limits<float >::max ();
@@ -714,6 +717,9 @@ __launch_bounds__(BLOCK_SIZE)
714717 s_distances[i] = l2_norms[old_neighbors[i % SKEWED_MAX_NUM_BI_SAMPLES]] +
715718 l2_norms[new_neighbors[i / SKEWED_MAX_NUM_BI_SAMPLES]] -
716719 2.0 * s_distances[i];
720+ // for fp32 vs fp16 precision differences resulting in negative distances when distance
721+ // should be 0 related issue: https://github.com/rapidsai/cuvs/issues/991
722+ s_distances[i] = s_distances[i] < 0 .0f ? 0 .0f : s_distances[i];
717723 }
718724 } else {
719725 s_distances[i] = std::numeric_limits<float >::max ();
You can’t perform that action at this time.
0 commit comments