Skip to content

Commit f80902c

Browse files
ssnlezyang
authored andcommitted
update Tensor.new doc
1 parent 96c6652 commit f80902c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

torch/tensor.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ class _TensorBase(object):
1414
# CUDA case, which handles constructing the tensor on the same GPU
1515
# as this tensor.
1616
def new(self, *args, **kwargs):
17-
"""Constructs a new tensor of the same data type."""
17+
"""Constructs a new tensor of the same data type.
18+
19+
Any valid argument combination to the Tensor constructor is accepted by
20+
this method, including sizes, :class:`torch.Storage`, numpy ndarray,
21+
Python Sequence, etc. See :class:`torch.Tensor` for more details.
22+
23+
.. note:: For CUDA tensors, this method will create new tensor on the
24+
same device as this tensor.
25+
"""
1826
return self.__class__(*args, **kwargs)
1927

2028
def type_as(self, tensor):

0 commit comments

Comments
 (0)