提交 3f5e8e9c 编写于 作者: T thunder 提交者: thunder

docs(mge/functional): update copy example

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