ml-explore / mlx-swift

Swift API for MLX
https://ml-explore.github.io/mlx-swift/
MIT License
668 stars 53 forks source link

Support MLXArray initialization from nested Swift Arrays #161

Open awni opened 4 days ago

awni commented 4 days ago

This is mostly a convenience but it can be quite handy and we support it in Python:

let a = MLXArray([[7, 8], [9, 10]])
davidkoski commented 4 days ago

I need to play around with that. We can certainly do it for a fixed number of dimensions (we need an initializer for each number of dimensions). Maybe we can do something fancy with generics and gt an arbitrary number, but I think the types will be tricky.