Rate this Page

Function torch::stable::to(const torch::stable::Tensor&, torch::stable::Device, bool, bool)#

Function Documentation#

inline torch::stable::Tensor torch::stable::to(const torch::stable::Tensor &self, torch::stable::Device device, bool non_blocking = false, bool copy = false)#

Convenience overload for moving a tensor to a device.

Moves the tensor to the specified device. This is a convenience wrapper around the full to() function.

Minimum compatible version: PyTorch 2.10.

Parameters:
  • self – The input tensor.

  • device – The target device.

  • non_blocking – If true, the operation may be asynchronous. Defaults to false.

  • copy – If true, always create a copy. Defaults to false.

Returns:

A tensor on the specified device.