Commit 2b67d57
authored
Fix pdist numerical issue on large input size (#2181)
This is to fix #2021.
The current algorithm uses the following formula to calculate index and
is numerically unstable at cases when n goes large (and j=n-1). Need
sqrt to be in double precision to ensure correct results after casting
into int. This change also aligns with cuda implementation.
https://github.com/intel/torch-xpu-ops/blob/779f89911779b8c7296aaec3cf74945c18acc270/src/ATen/native/xpu/sycl/DistanceKernels.cpp#L732
<img width="1322" height="138" alt="image"
src="https://github.com/user-attachments/assets/b7fa1515-eb29-436b-b14e-ac2c393df730"
/>1 parent e78fc05 commit 2b67d57
1 file changed
+7
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
729 | 729 | | |
730 | 730 | | |
731 | 731 | | |
732 | | - | |
| 732 | + | |
733 | 733 | | |
734 | 734 | | |
735 | 735 | | |
| |||
760 | 760 | | |
761 | 761 | | |
762 | 762 | | |
763 | | - | |
764 | | - | |
| 763 | + | |
| 764 | + | |
765 | 765 | | |
766 | 766 | | |
767 | 767 | | |
| |||
778 | 778 | | |
779 | 779 | | |
780 | 780 | | |
781 | | - | |
782 | | - | |
| 781 | + | |
| 782 | + | |
783 | 783 | | |
784 | 784 | | |
785 | 785 | | |
| |||
805 | 805 | | |
806 | 806 | | |
807 | 807 | | |
808 | | - | |
809 | | - | |
810 | 808 | | |
811 | 809 | | |
812 | 810 | | |
| |||
815 | 813 | | |
816 | 814 | | |
817 | 815 | | |
818 | | - | |
819 | | - | |
| 816 | + | |
| 817 | + | |
820 | 818 | | |
821 | 819 | | |
822 | 820 | | |
| |||
0 commit comments