Table of Contents
Shortcuts

# torch.Tensor.type

Tensor.type(dtype=None, non_blocking=False, **kwargs) → str or Tensor

  Returns the type if dtype is 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 `async` in place of the `non_blocking` argument. The `async` arg is deprecated.

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.