Use random64 in Fischer-Yates algorithm for large N (#143682)

Fixes bug in randperm https://nbsanity.com/static/a4774194938414dedcec7d6e99727d31/Shuffling_20in_20torch_20vs_20numpy-public.html

Pull Request resolved: https://github.com/pytorch/pytorch/pull/143682
Approved by: https://github.com/eqy, https://github.com/albanD
This commit is contained in:
Natalia Gimelshein
2024-12-25 01:19:17 +00:00
committed by PyTorch MergeBot
parent 27b0d41f0a
commit 7013be0094
5 changed files with 40 additions and 20 deletions

View File

@ -246,7 +246,7 @@ class TestDatasetRandomSplit(TestCase):
range(10), [3, 7], generator=torch.Generator().manual_seed(1)
)
],
[[5, 6, 1], [2, 0, 8, 9, 3, 7, 4]],
[[8, 4, 2], [0, 7, 5, 3, 6, 9, 1]],
)
self.assertEqual(
random_split(