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

Support signed value for Tensor::arange #1238

Merged
merged 3 commits into from
Feb 7, 2024

Conversation

Nikaidou-Shinku
Copy link
Contributor

Pull Request Template

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

#1234

Changes

Make Tensor::arange and all internal methods accept a Range<i64> instead of Range<usize> to support ranges of signed value.

Testing

bash ./run-checks.sh all was passed.

Copy link

codecov bot commented Feb 2, 2024

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (9df2071) 84.41% compared to head (a766252) 84.38%.
Report is 9 commits behind head on main.

Files Patch % Lines
burn-tch/src/ops/int_tensor.rs 0.00% 9 Missing ⚠️
burn-autodiff/src/ops/int_tensor.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1238      +/-   ##
==========================================
- Coverage   84.41%   84.38%   -0.04%     
==========================================
  Files         549      550       +1     
  Lines       61952    62206     +254     
==========================================
+ Hits        52295    52490     +195     
- Misses       9657     9716      +59     

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

Copy link
Member

@nathanielsimard nathanielsimard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw some naming problems related to arange, I think we could fix this within this PR.

burn-tensor/src/tensor/api/int.rs Outdated Show resolved Hide resolved
burn-tensor/src/tensor/ops/tensor.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@antimora antimora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. A new unit test should be added to test all new edge cases (negatives and 0, overflow range).

  2. Extra caution when casting usize to i64 because it overflow.

@nathanielsimard
Copy link
Member

  1. A new unit test should be added to test all new edge cases (negatives and 0, overflow range).
  2. Extra caution when casting usize to i64 because it overflow.

I think we should check if we can replace the usize by i64 instead of casting in most places.

@Nikaidou-Shinku
Copy link
Contributor Author

I moved the functions about arange to int_tensor.rs, and add some test cases for 0 and negative numbers.
Regarding overflow, I don't have any good ideas. I noticed that for most cases where arange is used in the test cases, the range is taken from the shape of tensors. In this case, when an overflow occurs, I don't know what else to do but crash the program.

Copy link
Collaborator

@antimora antimora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nathanielsimard nathanielsimard merged commit 419e53b into tracel-ai:main Feb 7, 2024
14 checks passed
@Nikaidou-Shinku Nikaidou-Shinku deleted the feat/signed-arange branch February 22, 2024 07:23
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.

3 participants