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

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

1 participant