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

Nonzero should return an empty vec for zero tensors #2212

Merged
merged 5 commits into from
Sep 3, 2024
Merged

Conversation

laggui
Copy link
Member

@laggui laggui commented Aug 28, 2024

Checklist

  • Confirmed that run-checks all script has been executed.

Related Issues/PRs

Fixes #1946 #2180

Blocked by this wgpu fix in cubecl

Changes

Tensors where all elements are zero should return an empty vector since no valid indices represent non-zero elements.

Testing

Added unit test (currently fails with wgpu without the fix).

Copy link

codecov bot commented Aug 28, 2024

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Project coverage is 85.88%. Comparing base (96a2340) to head (7167674).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/burn-tch/src/ops/bool_tensor.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2212   +/-   ##
=======================================
  Coverage   85.88%   85.88%           
=======================================
  Files         707      707           
  Lines       89805    89819   +14     
=======================================
+ Hits        77130    77143   +13     
- Misses      12675    12676    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@laggui laggui requested a review from nathanielsimard August 28, 2024 18:01
@laggui
Copy link
Member Author

laggui commented Aug 28, 2024

Huh, I expected the added unit test to fail on wgpu without the cubecl fix merged 🤔 it fails locally when I test the same operation in a simple program

let tensor = Tensor::<Wgpu, 1, Bool>::from([false, false, false, false, false]);
let output = tensor.nonzero();
thread 'main' panicked at /home/laggui/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cubecl-runtime-0.2.0/src/memory_management/memory_pool/small.rs:109:9:
assertion `left == right` failed
  left: 0
 right: 32
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@laggui laggui merged commit cc214d3 into main Sep 3, 2024
11 checks passed
@laggui laggui deleted the fix/nonzero branch September 3, 2024 13:01
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.

bool nonzero panics when the entire tensor is false, on wgpu
2 participants