mlx icon indicating copy to clipboard operation
mlx copied to clipboard

Support initializing array from list of arrays

Open ccostes opened this issue 2 years ago • 3 comments

Running the snippet

import mlx.core as mx
a = mx.array([1.])
b = mx.array([2.])
mx.array([a,b])

produces error

----> [4] mx.array([a,b])

ValueError: Invalid type in array initialization<class 'mlx.core.array'>.

This works with numpy, so seems like a bug in mlx.

ccostes avatar Dec 25 '23 20:12 ccostes

This isn't so much a bug as a feature request. MLX is still missing a lot of features that NumPy has.

For now you can use mx.concatenate or mx.stack. Will mark this as an feature request.

awni avatar Dec 25 '23 21:12 awni

Got it, thanks! Will look into trying to implement it; seems like it might be straightforward.

I'm enjoying mlx so far!

ccostes avatar Dec 26 '23 02:12 ccostes

Adding on here, can this feature support initializing from a list that contains numpy arrays?

a = mx.array( [np.array(1), np.array(1)])

wjessup avatar Dec 27 '23 16:12 wjessup

This was closed in #325

awni avatar Jan 08 '24 19:01 awni