On this page
torch.Tensor.type
Tensor.type(dtype=None, non_blocking=False, **kwargs) → str or Tensor-
Returns the type if
dtypeis not provided, else casts this object to the specified type.If this is already of the correct type, no copy is performed and the original object is returned.
- Parameters
-
- dtype (dtype or string) – The desired type
- non_blocking (bool) – If
True, and the source is in pinned memory and destination is on the GPU or vice versa, the copy is performed asynchronously with respect to the host. Otherwise, the argument has no effect. - **kwargs – For compatibility, may contain the key
asyncin place of thenon_blockingargument. Theasyncarg is deprecated.
© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.Tensor.type.html