Browse Source

Merge pull request #478 from thunderstudying:docstring-copy

GitOrigin-RevId: 123f95959d
release-1.11.1
Megvii Engine Team 2 years ago
parent
commit
7655d99aa5
1 changed files with 10 additions and 11 deletions
  1. +10
    -11
      imperative/python/megengine/functional/tensor.py

+ 10
- 11
imperative/python/megengine/functional/tensor.py View File

@@ -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]


Loading…
Cancel
Save