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

unexpected behavior in f_indexer #912

Open
mlej8 opened this issue Nov 22, 2024 · 0 comments
Open

unexpected behavior in f_indexer #912

mlej8 opened this issue Nov 22, 2024 · 0 comments

Comments

@mlej8
Copy link

mlej8 commented Nov 22, 2024

hi, https://github.com/LaurentMazare/tch-rs/blob/main/src/tensor/index.rs#L336 any thoughts on using f_select here and propagate the error instead of select which panics ?

f_indexer is suppose to return Result<Tensor> but the usage of select means that it will panic instead of propagating an error.

    pub fn select(&self, dim: i64, index: i64) -> Tensor {
        self.f_select(dim, index).unwrap()
    }

why not directly have f_select there and propagate the error upwards

The purpose of having f_i is so that it allows the user to handle the indexing error, but if we panic, then there's no point in having fn f_i

@mlej8 mlej8 changed the title non safe operation in f_indexer unexpected behavior in f_indexer Nov 22, 2024
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

No branches or pull requests

1 participant