Skip to content

unexpected behavior in f_indexer #912

Open
@mlej8

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions