From 0b764cf2d2e96491b64c1d0fd740390d563b6958 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Mon, 19 Jul 2021 21:16:44 +0800 Subject: [PATCH] docs(mge/functional): add docs for megengine.functional.full_like GitOrigin-RevId: 391447e977e08a920deb05e6a7508d07a094784a --- .../python/megengine/functional/tensor.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) mode change 100644 => 100755 imperative/python/megengine/functional/tensor.py diff --git a/imperative/python/megengine/functional/tensor.py b/imperative/python/megengine/functional/tensor.py old mode 100644 new mode 100755 index c4ac041f0..1ecb71f74 --- a/imperative/python/megengine/functional/tensor.py +++ b/imperative/python/megengine/functional/tensor.py @@ -208,6 +208,29 @@ def full_like( ) -> Union[Tensor, SymbolVar]: """ Returns a tensor filled with given value with the same shape as input tensor. + + :param inp: input tensor. + :param value: target value. + :return: output tensor. + + 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.full_like(inp, 2) + print(out.numpy()) + + Outputs: + + .. testoutput:: + + [[2 2 2] + [2 2 2]] + """ (x,) = Const(value, dtype=inp.dtype, device=inp.device)(inp) if inp.shape is (): -- GitLab