Skip to content

MLX compatibility: indexing functions #466

Description

@ev-br

Towards #450.

test_take_along_axis fails because of a quirck of the MLX function signature: the axis argument is optional in the spec but MLX requires it:

This is array-api-strict:

>>> import array_api_strict as xp
TypeError: take_along_axis() takes 2 positional arguments but 3 were given
>>> xp.take_along_axis(xp.asarray([False], dtype=xp.bool), xp.asarray([], dtype=xp.int32), axis=None)
empty((0,), dtype=array_api_strict.bool)
>>> xp.take_along_axis(xp.asarray([False], dtype=xp.bool), xp.asarray([], dtype=xp.int32))
empty((0,), dtype=array_api_strict.bool)

and this is MLX:

>>> import mlx.core as mx
>>> mx.take_along_axis(mx.asarray([False], dtype=mx.bool_), mx.asarray([], dtype=mx.int32), None)
array([], dtype=bool)
>>> mx.take_along_axis(mx.asarray([False], dtype=mx.bool_), mx.asarray([], dtype=mx.int32))
Traceback (most recent call last):
  File "<python-input-30>", line 1, in <module>
    mx.take_along_axis(mx.asarray([False], dtype=mx.bool_), mx.asarray([], dtype=mx.int32))
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: take_along_axis(): incompatible function arguments. The following argument types are supported:
    1. take_along_axis(a: array, /, indices: array, axis: int | None = None, *, stream: StreamOrDevice = None) -> array

Invoked with types: mlx.core.array, mlx.core.array

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions