mirror of
https://github.com/ml-explore/mlx.git
synced 2025-06-25 01:41:17 +08:00
Fix copy bug with many dims (#1137)
This commit is contained in:
parent
23406c9e9e
commit
fb71a82ada
@ -256,7 +256,7 @@ void copy_general_general(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int size = std::accumulate(
|
int size = std::accumulate(
|
||||||
data_shape.begin() - 5, data_shape.end(), 1, std::multiplies<int>());
|
data_shape.end() - 5, data_shape.end(), 1, std::multiplies<int>());
|
||||||
for (int i = 0; i < src.size(); i += size) {
|
for (int i = 0; i < src.size(); i += size) {
|
||||||
stride_t src_offset = i_offset + elem_to_loc(i, data_shape, i_strides);
|
stride_t src_offset = i_offset + elem_to_loc(i, data_shape, i_strides);
|
||||||
stride_t dst_offset = o_offset + elem_to_loc(i, dst.shape(), o_strides);
|
stride_t dst_offset = o_offset + elem_to_loc(i, dst.shape(), o_strides);
|
||||||
|
@ -1270,6 +1270,10 @@ class TestArray(mlx_tests.MLXTestCase):
|
|||||||
x[:, 0] = 1.0
|
x[:, 0] = 1.0
|
||||||
self.assertTrue(mx.array_equal(x[:, 0], mx.ones((2, 4, 5, 3))))
|
self.assertTrue(mx.array_equal(x[:, 0], mx.ones((2, 4, 5, 3))))
|
||||||
|
|
||||||
|
x = mx.zeros((2, 2, 2, 2, 2, 2))
|
||||||
|
x[0, 0] = 1
|
||||||
|
self.assertTrue(mx.array_equal(x[0, 0], mx.ones((2, 2, 2, 2))))
|
||||||
|
|
||||||
def test_array_at(self):
|
def test_array_at(self):
|
||||||
a = mx.array(1)
|
a = mx.array(1)
|
||||||
a = a.at[None].add(1)
|
a = a.at[None].add(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user