File tree Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Expand file tree Collapse file tree 1 file changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -270,22 +270,30 @@ def set_default_tensor_type(t):
270
270
271
271
272
272
def set_default_dtype (d ):
273
- r"""Sets the default floating point dtype to :attr:`d`. This type will be
274
- used as default floating point type for type inference in
275
- :func:`torch.tensor`.
273
+ r"""Sets the default floating point dtype to :attr:`d`.
274
+ This dtype is:
275
+ 1. The inferred dtype for python floats in :func:`torch.tensor`.
276
+ 2. Used to infer dtype for python complex numbers. The default complex dtype is set to
277
+ ``torch.complex128`` if default floating point dtype is ``torch.float64``,
278
+ otherwise it's set to ``torch.complex64``
276
279
277
280
The default floating point dtype is initially ``torch.float32``.
278
281
279
282
Args:
280
283
d (:class:`torch.dtype`): the floating point dtype to make the default
281
284
282
285
Example::
283
-
284
- >>> torch.tensor([1.2, 3]).dtype # initial default for floating point is torch.float32
286
+ >>> # initial default for floating point is torch.float32
287
+ >>> torch.tensor([1.2, 3]).dtype
285
288
torch.float32
289
+ >>> # initial default for floating point is torch.complex64
290
+ >>> torch.tensor([1.2, 3j]).dtype
291
+ torch.complex64
286
292
>>> torch.set_default_dtype(torch.float64)
287
- >>> torch.tensor([1.2, 3]).dtype # a new floating point tensor
293
+ >>> torch.tensor([1.2, 3]).dtype # a new floating point tensor
288
294
torch.float64
295
+ >>> torch.tensor([1.2, 3j]).dtype # a new complex tensor
296
+ torch.complex128
289
297
290
298
"""
291
299
_C ._set_default_dtype (d )
You can’t perform that action at this time.
0 commit comments