Fix copy bug with many dims (#1137)

This commit is contained in:
Awni Hannun 2024-05-17 21:10:03 -07:00 committed by GitHub
parent 23406c9e9e
commit fb71a82ada
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -256,7 +256,7 @@ void copy_general_general(
}
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) {
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);

View File

@ -1270,6 +1270,10 @@ class TestArray(mlx_tests.MLXTestCase):
x[:, 0] = 1.0
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):
a = mx.array(1)
a = a.at[None].add(1)