提交 7655d99a 编写于 作者: M Megvii Engine Team

Merge pull request #478 from thunderstudying:docstring-copy

GitOrigin-RevId: 123f95959dcbb2e0145252ba410eb116d4d2878b
......@@ -1049,17 +1049,16 @@ def copy(inp, device=None):
device: destination device.
Examples:
>>> import numpy as np
>>> import platform
>>> from megengine.device import get_device_count
>>> x = Tensor([1, 2, 3], np.int32)
>>> if 1 == get_device_count("gpu"):
... y = F.copy(x, "cpu1")
... print(y.numpy())
... else:
... y = F.copy(x, "xpu1")
... print(y.numpy())
[1 2 3]
>>> x = megengine.tensor([1, 2, 3], numpy.int32)
Tensor([1 2 3], dtype=int32, device=xpux:0)
>>> megengine.functional.copy(x, 'cpu1')
Tensor([1 2 3], dtype=int32, device=cpu1:0)
>>> megengine.functional.copy(x, 'xpu0')
Tensor([1 2 3], dtype=int32, device=xpu0:0)
"""
if device is None:
return apply(Identity(), inp)[0]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册