From 3f5e8e9c09d87c1e9baf486bf66abbd04768978c Mon Sep 17 00:00:00 2001 From: thunder <39192865+thunderstudying@users.noreply.github.com> Date: Sun, 28 Aug 2022 14:27:05 +0800 Subject: [PATCH] docs(mge/functional): update copy example --- imperative/python/megengine/functional/tensor.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/imperative/python/megengine/functional/tensor.py b/imperative/python/megengine/functional/tensor.py index 24eabf54..abeaa0c3 100755 --- a/imperative/python/megengine/functional/tensor.py +++ b/imperative/python/megengine/functional/tensor.py @@ -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]