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

PyO3: Add None and Tensor indexing to candle.Tensor #1098

Merged
merged 3 commits into from
Oct 20, 2023

Conversation

LLukas22
Copy link
Contributor

This adds the ability to expand tensor dimensions via a None index.
e.g.:

t = candle.rand((12, 12))
c = t[:, None, None, :] # shape is now (12,1,1,12)

Tensor indexing is also supported but similarly to candle-core its limited to 1D tensors.

candle-pyo3/src/lib.rs Outdated Show resolved Hide resolved
candle-pyo3/src/lib.rs Outdated Show resolved Hide resolved
@LLukas22
Copy link
Contributor Author

Alright should be good to go, i added the list indexing and made sure that it works outside of the first tensor dimension.

@LaurentMazare LaurentMazare merged commit b43ab6c into huggingface:main Oct 20, 2023
10 of 12 checks passed
@LaurentMazare
Copy link
Collaborator

Thanks!

EricLBuehler pushed a commit to EricLBuehler/candle that referenced this pull request Oct 25, 2023
…e#1098)

* Add proper `None` and `tensor` indexing

* Allow indexing via lists + allow tensor/list indexing outside of first dimension
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants