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

Indexing an mlx.array with list #908

Closed
amirhossein-razlighi opened this issue Mar 26, 2024 · 2 comments · Fixed by #1150
Closed

Indexing an mlx.array with list #908

amirhossein-razlighi opened this issue Mar 26, 2024 · 2 comments · Fixed by #1150
Labels
enhancement New feature or request

Comments

@amirhossein-razlighi
Copy link
Contributor

If we index an mlx.core.array type with a list, an exception occurs. While common convention in numpy or PyTorch is to return the given elements correctly. E.g:

import mlx.core as mx
import numpy as np
import torch

a = mlx.array([1,2,3])
a[[0,1]] # ValueError: Cannot index mlx array using the given type.

b  = np.array([1,2,3])
b[[0,1]] # array([1, 2])

c = torch.tensor([1,2,3])
c[[0,1]] # tensor([1, 2])

If it's a valid issue and we want to follow these convention in mlx, please let me know. I'll be happy to work on it!

@awni
Copy link
Member

awni commented Mar 26, 2024

Indeed.. I see no reason not to support using a list to index.

@awni awni added the enhancement New feature or request label Mar 26, 2024
@amirhossein-razlighi
Copy link
Contributor Author

Sure, great. I will start working on that

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

Successfully merging a pull request may close this issue.

2 participants