Sort the digest after merge to deal with floating point accuracy
Summary: When merging centroids together, we recalculate the mean and weight. This can sometimes lead to inaccuracy due to floating point arithmetic. In a bad scenario, this can actually lead to the digest being unsorted, which triggers assertions in the code. To fix this, sort the digest at the end of merge. Since this is bounded to 100 elements that are mostly sorted, this appears to be cheap according to benchmarks. Reviewed By: yfeldblum Differential Revision: D9213936 fbshipit-source-id: 5a2978a1b759b70206aef57245bef193aed65efd
Showing
Please register or sign in to comment