mirror of
https://github.com/ml-explore/mlx.git
synced 2025-06-24 17:31:16 +08:00
Fix put_along_axis for empty arrays (#2181)
This commit is contained in:
parent
8f3d208dce
commit
3aa9cf3f9e
@ -3175,6 +3175,10 @@ array scatter_axis(
|
||||
throw std::invalid_argument(msg.str());
|
||||
}
|
||||
|
||||
if (a.size() == 0) {
|
||||
return a;
|
||||
}
|
||||
|
||||
auto upd = astype(values, a.dtype(), s);
|
||||
|
||||
// Squeeze leading singletons out of update
|
||||
|
@ -1255,6 +1255,12 @@ class TestOps(mlx_tests.MLXTestCase):
|
||||
np.put_along_axis(out_np, np.array(indices), np.array(update), axis=-2)
|
||||
self.assertTrue(np.array_equal(out_np, np.array(out_mlx)))
|
||||
|
||||
a = mx.array([], mx.float32)
|
||||
b = mx.put_along_axis(a, a, a, axis=None)
|
||||
mx.eval(b)
|
||||
self.assertEqual(b.size, 0)
|
||||
self.assertEqual(b.shape, a.shape)
|
||||
|
||||
def test_split(self):
|
||||
a = mx.array([1, 2, 3])
|
||||
splits = mx.split(a, 3)
|
||||
|
Loading…
Reference in New Issue
Block a user