megengine.functional.copy

copy(inp, device=None)[source]

Copies tensor to another device.

Parameters
  • inp – input tensor.

  • device – destination device.

Examples

>>> import numpy as np
>>> x = Tensor([1, 2, 3], np.int32)
>>> F.copy(x, 'cpu1')
Tensor([1 2 3], dtype=int32, device=cpu1:0)
>>> F.copy(x, 'xpu0')
Tensor([1 2 3], dtype=int32, device=xpu0:0)