Fix the error in the note about torch.device documentation.#16839
Closed
JirenJin wants to merge 1 commit into
Closed
Fix the error in the note about torch.device documentation.#16839JirenJin wants to merge 1 commit into
torch.device documentation.#16839JirenJin wants to merge 1 commit into
Conversation
ssnl
approved these changes
Feb 7, 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
…h#16839) Summary: This PR is a simple fix for the mistake in the first note for `torch.device` in the "tensor attributes" doc.  ``` >>> # You can substitute the torch.device with a string >>> torch.randn((2,3), 'cuda:1') ``` Above code will cause error like below: ``` --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-53-abdfafb67ab1> in <module>() ----> 1 torch.randn((2,3), 'cuda:1') TypeError: randn() received an invalid combination of arguments - got (tuple, str), but expected one of: * (tuple of ints size, torch.Generator generator, Tensor out, torch.dtype dtype, torch.layout layout, torch.device device, bool requires_grad) * (tuple of ints size, Tensor out, torch.dtype dtype, torch.layout layout, torch.device device, bool requires_grad) ``` Simply adding the argument name `device` solves the problem: `torch.randn((2,3), device='cuda:1')`. However, another concern is that this note seems redundant as **there is already another note covering this usage**:  So maybe it's better to just remove this note? Pull Request resolved: pytorch#16839 Reviewed By: ezyang Differential Revision: D13989209 Pulled By: gchanan fbshipit-source-id: ac255d52528da053ebfed18125ee6b857865ccaf
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.
This PR is a simple fix for the mistake in the first note for

torch.devicein the "tensor attributes" doc.Above code will cause error like below:
Simply adding the argument name
devicesolves the problem:torch.randn((2,3), device='cuda:1').However, another concern is that this note seems redundant as there is already another note covering this usage:

So maybe it's better to just remove this note?