-
Notifications
You must be signed in to change notification settings - Fork 661
Relax stride check in unit dimensions. #6285
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,6 +89,20 @@ def test_torch_nocopy(device: str): | |
| np.testing.assert_array_equal(ndd_tensor.cpu(), [42, 2, 3]) | ||
|
|
||
|
|
||
| @attr("pytorch") | ||
| @params(("cpu",), ("gpu",)) | ||
| def test_from_torch(device: str): | ||
| import torch | ||
|
|
||
| if version.parse(torch.__version__) < version.parse("2.6.0"): | ||
| raise SkipTest("Requires PyTorch >= 2.6.0") | ||
|
Comment on lines
+97
to
+98
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The PR description states the problem occurs in older PyTorch versions (strides of 1 for unit dimensions in DLPack). This test skips on
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @greptileai: The tests fails with PyTorch 2.7.1, so the check against 2.6.0 doesn't defeat it.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right—if the stride issue still occurs in PyTorch 2.7.1, then the Tip: You can give me more context with .greptile/rules so I get this right next time. |
||
|
|
||
| inpt = torch.arange(1, 5).reshape((1, 2, 2)) | ||
| ndd_tensor = ndd.as_tensor(inpt) | ||
|
|
||
| np.testing.assert_array_equal(ndd_tensor.cpu(), [[[1, 2], [3, 4]]]) | ||
mzient marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| @attr("pytorch") | ||
| @params(("cpu",), ("gpu",)) | ||
| def test_tensor_to_torch(device: str): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last_non_one_dimis initialised but never read after the simplification — it was part of the oldstride_from_shape_collapsedlogic that was removed. Most compilers will warn about it.