Closed
Conversation
ngimel
approved these changes
Jun 16, 2020
Collaborator
ngimel
left a comment
There was a problem hiding this comment.
It's good we are getting rid of tolist()s.
| # which takes care of negative strides if present. | ||
| torch_fn, np_fn = funcs | ||
| self.compare_with_numpy(torch_fn, np_fn, data, device, dtype) | ||
| if dtype.is_floating_point or dtype.is_complex: |
Collaborator
There was a problem hiding this comment.
so this ignored device altogether? Nice.
Collaborator
Author
There was a problem hiding this comment.
No. Historically it would create a list from a tensor and then compare_with_numpy would put that list into a tensor on the appropriate device.
The updated test just has fewer steps to get to the same place.
Contributor
facebook-github-bot
left a comment
There was a problem hiding this comment.
@mruberry has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Contributor
xwang233
pushed a commit
to xwang233/pytorch
that referenced
this pull request
Jun 20, 2020
Summary: Currently compare_with_numpy requires a device and dtype, but these arguments are ignored if a tensor is provided. This PR updates the function to only take device and dtype if a tensor-like object is given. This should prevent confusion that you could, for example, pass a CPU float tensor but provided a CUDA device and integer dtype. Several tests are updated to reflect this behavior. Pull Request resolved: pytorch#40064 Differential Revision: D22058072 Pulled By: mruberry fbshipit-source-id: b494bb759855977ce45b79ed3ffb0319a21c324c
laurentdupin
pushed a commit
to laurentdupin/pytorch
that referenced
this pull request
Apr 24, 2026
Summary: Currently compare_with_numpy requires a device and dtype, but these arguments are ignored if a tensor is provided. This PR updates the function to only take device and dtype if a tensor-like object is given. This should prevent confusion that you could, for example, pass a CPU float tensor but provided a CUDA device and integer dtype. Several tests are updated to reflect this behavior. Pull Request resolved: pytorch#40064 Differential Revision: D22058072 Pulled By: mruberry fbshipit-source-id: b494bb759855977ce45b79ed3ffb0319a21c324c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently compare_with_numpy requires a device and dtype, but these arguments are ignored if a tensor is provided. This PR updates the function to only take device and dtype if a tensor-like object is given. This should prevent confusion that you could, for example, pass a CPU float tensor but provided a CUDA device and integer dtype.
Several tests are updated to reflect this behavior.