Rate this Page

torch.Tensor.type#

Tensor.type(dtype=None,non_blocking=False,**kwargs)strorTensor#

Returns the type ifdtype is not provided, else casts this object tothe specified type.

If this is already of the correct type, no copy is performed and theoriginal object is returned.

Parameters
  • dtype (dtype orstring) – The desired type

  • non_blocking (bool) – IfTrue, and the source is in pinned memoryand destination is on the GPU or vice versa, the copy is performedasynchronously with respect to the host. Otherwise, the argumenthas no effect.

  • **kwargs – For compatibility, may contain the keyasync in place ofthenon_blocking argument. Theasync arg is deprecated.