Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Ellipsis for broadcasting with einsum #1717

Open
ashegde opened this issue Dec 18, 2024 · 1 comment
Open

[Feature] Ellipsis for broadcasting with einsum #1717

ashegde opened this issue Dec 18, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@ashegde
Copy link

ashegde commented Dec 18, 2024

I noticed that using mlx.core.einsum with ellipsis produces an error. In numpy, I've found that ellipses with np.einsum can be quite useful. Are there plans of including this feature in the future?

To reproduce
MLX code:

import mlx.core as mx

x = mx.random.normal(shape=(3, 4, 5, 6))
y = mx.random.normal(shape=(3, 4, 5, 6))

z = mx.einsum('...ij,...kj->...ik', x, y)

and the resulting error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[4], [line 7]
      [4] x = mx.random.normal(shape=(3, 4, 5, 6))
      [5] y = mx.random.normal(shape=(3, 4, 5, 6))
----> [7] z = mx.einsum('...ij,...kj->...ik', x, y)

ValueError: [einsum] Subscripts must be letters, but got '.'.

In contrast, the following code works without issue in numpy:

import numpy as np

x = np.random.normal(size=(3, 4, 5, 6))
y = np.random.normal(size=(3, 4, 5, 6))

z = np.einsum('...ij,...kj->...ik', x, y)

Thanks!

@awni awni added the enhancement New feature or request label Dec 18, 2024
@awni
Copy link
Member

awni commented Dec 18, 2024

Indeed we should add support for ellipsis in the subscripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants