-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Describe the bug
An important operation that is missing from MLX's implementation of __array_namespace__ is asarray. Without this operation array agnostic code cannot easily create new arrays and must resort to awkward code like:
a(Z) if (a := getattr(xp, "asarray", None)) else xp.array(Z)To Reproduce
>>> import mlx.core as mx
>>> x=mx.array([1,2,3])
>>> x.__array_namespace__().asarray([4,5,6])
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
x.__array_namespace__().asarray([4,5,6])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'mlx.core' has no attribute 'asarray'. Did you mean: 'array'?Expected behavior
>>> import mlx.core as mx
>>> x=mx.array([1,2,3])
>>> x.__array_namespace__().asarray([4,5,6])
array([4, 5, 6], dtype=int32)Desktop:
- OS Version: Tahoe 26.0.1
- Version:
mlx==0.30.0
Additional context
Related to #48. However that issue does not contain a list of missing APIs, making organized work towards implementing all of them difficult.
justinchuby
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request