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

Simplify Tensor::unsqueeze_dims(); improve handling of negative indicies. #2572

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

crutcher
Copy link

@crutcher crutcher commented Dec 1, 2024

Checklist

  • Confirmed that run-checks all script has been executed.
  • Made sure the book is up to date with changes in this PR.

Related Issues/PRs

f8c845d

Changes

Independently re-discovered the unsqueeze bug fixed on HEAD at: f8c845d

This PR makes the tests more aggressive for negative offsets greater than -1; and accumulation of negative offsets.

Independently re-discovered the unsqueeze bug fixed on HEAD at:
tracel-ai@f8c845d

This PR makes the tests more aggressive for negative offsets greater
than -1; and accumulation of negative offsets.
@crutcher crutcher marked this pull request as draft December 1, 2024 22:46
@crutcher crutcher changed the title Make Tensor::unsqueeze() with negative dims test more paranoid. [wip] Tensor::unsqueeze() with negative dims < -1 is broken. Dec 1, 2024
@crutcher
Copy link
Author

crutcher commented Dec 1, 2024

failures:

---- tests::squeeze::tests::should_unsqueeze_dims_complex_negatives stdout ----
thread 'tests::squeeze::tests::should_unsqueeze_dims_complex_negatives' panicked at /home/crutcher/git/burn/burn/crates/burn-tensor/src/tensor/api/base.rs:779:26:
source slice length (2) does not match destination slice length (1)

---- tests::squeeze::tests::should_unsqueeze_dims_negative_two stdout ----
thread 'tests::squeeze::tests::should_unsqueeze_dims_negative_two' panicked at /home/crutcher/git/burn/burn/crates/burn-tensor/src/tensor/api/base.rs:781:44:
source slice length (3) does not match destination slice length (4)


failures:
    tests::squeeze::tests::should_unsqueeze_dims_complex_negatives
    tests::squeeze::tests::should_unsqueeze_dims_negative_two

@crutcher
Copy link
Author

crutcher commented Dec 1, 2024

There was a previous PR to try and address this, but it didn't handle -2 and other negatives correctly: f8c845d

@crutcher
Copy link
Author

crutcher commented Dec 1, 2024

@laggui this hits your previous PR; I'll try and work a fix up later tonight.

@crutcher crutcher changed the title [wip] Tensor::unsqueeze() with negative dims < -1 is broken. [wip] Tensor::unsqueeze_dims() with negative dims < -1 is broken. Dec 1, 2024
@crutcher crutcher changed the title [wip] Tensor::unsqueeze_dims() with negative dims < -1 is broken. Simplify Tensor::unsqueeze_dims(); improve handling of negative indicies. Dec 2, 2024
@crutcher crutcher marked this pull request as ready for review December 2, 2024 05:51
@laggui laggui self-requested a review December 2, 2024 12:35
Copy link

codecov bot commented Dec 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.86%. Comparing base (3dc4b43) to head (047bac3).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2572      +/-   ##
==========================================
- Coverage   81.86%   81.86%   -0.01%     
==========================================
  Files         833      833              
  Lines      106465   106459       -6     
==========================================
- Hits        87162    87156       -6     
  Misses      19303    19303              

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

@crutcher
Copy link
Author

crutcher commented Dec 2, 2024

I recognize that my limited understanding of the api means that the previous versions of the test were broken (setting the wrong target dim count); but they still showed a problem when that was fixed.

This PR works cleanly with the new test; and the simplified logic has fewer cases

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.

1 participant