From b7fe6a27ee0b8e5ab6c8a4008cde486b50905a57 Mon Sep 17 00:00:00 2001 From: Asthestarsfalll <1186454801@qq.com> Date: Sun, 26 Dec 2021 20:21:48 +0800 Subject: [PATCH] docs(mge/functional): update functional.ones_like docstring --- .../python/megengine/functional/tensor.py | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/imperative/python/megengine/functional/tensor.py b/imperative/python/megengine/functional/tensor.py index e8ff2e6a..67693ace 100755 --- a/imperative/python/megengine/functional/tensor.py +++ b/imperative/python/megengine/functional/tensor.py @@ -240,32 +240,19 @@ def zeros_like(inp: Union[Tensor, SymbolVar]) -> Union[Tensor, SymbolVar]: def ones_like(inp: Union[Tensor, SymbolVar]) -> Union[Tensor, SymbolVar]: - r"""Returns a ones tensor with the same shape as input tensor. + r"""Returns a tensor filled with ones with the same shape and data type as input tensor. Args: - inp: input tensor. + inp (Tensor): input tensor. Return: - output tensor. + a tensor containing ones. Examples: - - .. testcode:: - - import numpy as np - from megengine import tensor - import megengine.functional as F - - inp = tensor(np.arange(1, 7, dtype=np.int32).reshape(2,3)) - out = F.ones_like(inp) - print(out.numpy()) - - Outputs: - - .. testoutput:: - - [[1 1 1] - [1 1 1]] + >>> input = F.arange(6, dtype='int32').reshape(2,3) + >>> F.ones_like(input) + Tensor([[1 1 1] + [1 1 1]], dtype=int32, device=xpux:0) """ return full_like(inp, 1.0) -- GitLab