copy

tripy.copy(input: Tensor, device: device) Tensor[source]

Returns a copy of the input tensor on the target device.

Parameters:
  • input (Tensor) – [dtype=T1] Tensor that will be copied

  • device (device) – The target device.

Returns:

[dtype=T1] A copy of input tensor on target device.

Return type:

Tensor

TYPE CONSTRAINTS:
Example
Example
1input = tp.Tensor([1, 2], device=tp.device("gpu"))
2output = tp.copy(input, tp.device("cpu"))
>>> input
tensor([1, 2], dtype=int32, loc=gpu:0, shape=(2,))
>>> output
tensor([1, 2], dtype=int32, loc=cpu:0, shape=(2,))