mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
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: https://github.com/pytorch/pytorch/pull/16839 Reviewed By: ezyang Differential Revision: D13989209 Pulled By: gchanan fbshipit-source-id: ac255d52528da053ebfed18125ee6b857865ccaf |
||
|---|---|---|
| .. | ||
| _static/img | ||
| _templates | ||
| notes | ||
| scripts | ||
| autograd.rst | ||
| bottleneck.rst | ||
| checkpoint.rst | ||
| conf.py | ||
| cpp_extension.rst | ||
| cuda_deterministic_backward.rst | ||
| cuda_deterministic.rst | ||
| cuda.rst | ||
| cudnn_deterministic.rst | ||
| cudnn_persistent_rnn.rst | ||
| data.rst | ||
| distributed_deprecated.rst | ||
| distributed.rst | ||
| distributions.rst | ||
| dlpack.rst | ||
| hub.rst | ||
| index.rst | ||
| jit.rst | ||
| model_zoo.rst | ||
| multiprocessing.rst | ||
| nn.rst | ||
| onnx.rst | ||
| optim.rst | ||
| sparse.rst | ||
| storage.rst | ||
| tensor_attributes.rst | ||
| tensors.rst | ||
| torch.rst | ||
| type_info.rst | ||