Replaced "from_numpy" with "as_tensor" in docs.#16587
Closed
sebftw wants to merge 1 commit into
Closed
Conversation
ssnl
approved these changes
Jan 31, 2019
Contributor
facebook-github-bot
left a comment
There was a problem hiding this comment.
@gchanan has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
laurentdupin
pushed a commit
to laurentdupin/pytorch
that referenced
this pull request
Apr 24, 2026
Summary: In the warning box on https://pytorch.org/docs/stable/tensors.html#torch.Tensor.new_tensor it says: > new_tensor() always copies data. [...] If you have a numpy array and want to avoid a copy, use **torch.from_numpy()**. But then further up the page we have another warning box with the message: > torch.tensor() always copies data. [...] If you have a numpy array and want to avoid a copy, use **torch.as_tensor()**. Now I believe this is just a small oversight, since from_numpy is to be deprecated in favour of as_tensor. See for example pytorch#6885 and pytorch#8611. I suggest to just use **torch.as_tensor()** in both of the warning boxes. cc gchanan Pull Request resolved: pytorch#16587 Differential Revision: D13897038 Pulled By: gchanan fbshipit-source-id: 2eb3cd47d2c0b5bf4350f980de3be9fe59b4a846
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.
📚 Documentation
In the warning box on https://pytorch.org/docs/stable/tensors.html#torch.Tensor.new_tensor it says:
But then further up the page we have another warning box with the message:
Now I believe this is just a small oversight, since from_numpy is to be deprecated in favour of as_tensor. See for example #6885 and #8611. I suggest to just use torch.as_tensor() in both of the warning boxes.
cc @gchanan