Skip to content

Conversation

@Aravind-11
Copy link

Description

Fixes #854 - linspace now correctly handles int64 dtype

Changes

  • Modified aten_linspace to compute in floating-point then cast to target dtype
  • This matches PyTorch's behavior and fixes integer division precision loss

Testing

Manually verified: linspace(0, 10, 5, dtype=int64) now produces correct output [0, 2, 5, 7, 10]

Questions

Where should I add automated test cases for this fix? Happy to add tests wherever you suggest!

@Aravind-11
Copy link
Author

Description

Fixes #854 - linspace now correctly handles int64 dtype

Changes

  • Modified aten_linspace to compute in floating-point then cast to target dtype
  • This matches PyTorch's behavior and fixes integer division precision loss

Testing

Manually verified: linspace(0, 10, 5, dtype=int64) now produces correct output [0, 2, 5, 7, 10]

Questions

Where should I add automated test cases for this fix? Happy to add tests wherever you suggest!

Who can review : @justinchuby

@codecov
Copy link

codecov bot commented Nov 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.11%. Comparing base (a1be5c8) to head (974f663).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2693   +/-   ##
=======================================
  Coverage   70.11%   70.11%           
=======================================
  Files         225      225           
  Lines       27083    27085    +2     
  Branches     2721     2721           
=======================================
+ Hits        18990    18992    +2     
  Misses       7153     7153           
  Partials      940      940           

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

@justinchuby
Copy link
Collaborator

Thanks. Could you unskip the tests:

@Aravind-11
Copy link
Author

Thanks. Could you unskip the tests:

Thank you for reviewing! Done.

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

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

[torchlib] linspace results do not match with PyTorch when dtype is int64

2 participants