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

Improve slicing #91

Open
FL33TW00D opened this issue Feb 19, 2024 · 0 comments
Open

Improve slicing #91

FL33TW00D opened this issue Feb 19, 2024 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@FL33TW00D
Copy link
Collaborator

FL33TW00D commented Feb 19, 2024

Currently our slice definition looks as follows:

    pub fn slice<D: std::ops::RangeBounds<usize>>(&self, ranges: &[D]) -> anyhow::Result<Tensor> {
        ///...impl...
    }

This is very user hostile, as the user must provide a homogeneous collection of ranges.

let y = x.slice(&[0..5, 0..6, 0..7]);

This is very annoying, as you may only care about one of the dimensions, it would be better to have something like

let y = x.slice(&[.., 0..6, ..]);

Unfortunately, this doesn't work, because the collection is now heterogeneous (i.e is made up of 2xRangeFull and 1xRange).

Therefore, we need to use a macro, much like ndarray.

let y = x.slice(s![.., 0..6, ..]);

This API gives the illusion of heterogeneous collections, which is what we want.

@FL33TW00D FL33TW00D added enhancement New feature or request help wanted Extra attention is needed labels Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant