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

Crash when calling Tensor::nonzero() on a tensor that all values are zero. #2180

Closed
KhaledHosseini opened this issue Aug 19, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@KhaledHosseini
Copy link

KhaledHosseini commented Aug 19, 2024

Describe the bug

Crash when calling Tensor::nonzero() on a tensor that all values are zero. Is this a bug or is the behavior intentional? (because of zero size tensor).
To Reproduce

use burn::{
    backend::wgpu::Wgpu,
    tensor::{backend::Backend, Tensor},
};

type MyBackend= Wgpu;

fn main() {
   let device = Default::default();
   let bools = Tensor::<MyBackend, 1>::zeros([1000], &device).bool();
   // let bools = Tensor::<MyBackend, 1>::full([1000],0.0, &device).bool();
    let non_zero_indices = Tensor::nonzero(bools); // panics ... we need to use Tensor::any() before calling this function.
}

Expected behavior
Should return a vector of zero size tensors or a vector of Option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants