Fix GPU sort for large arrays (#1285)

* Fix GPU sort for large arrays
This commit is contained in:
Jagrit Digani
2024-07-24 14:37:10 -07:00
committed by GitHub
parent ebd7135b50
commit 7f914365fd
4 changed files with 34 additions and 25 deletions

View File

@@ -1840,6 +1840,15 @@ class TestOps(mlx_tests.MLXTestCase):
self.assertTrue(np.array_equal(c_np, c_mx))
self.assertEqual(b_mx.dtype, c_mx.dtype)
# Test very large array
if mx.default_device() == mx.gpu:
a_np = np.random.normal(20, 20, size=(2**22)).astype(np.float32)
a_mx = mx.array(a_np)
b_np = np.sort(a_np)
b_mx = mx.sort(a_mx)
self.assertTrue(np.array_equal(b_np, b_mx))
def test_partition(self):
shape = (3, 4, 5)
for dtype in ("int32", "float32"):