diff --git a/imperative/python/megengine/functional/tensor.py b/imperative/python/megengine/functional/tensor.py old mode 100644 new mode 100755 index c4ac041f0170199d27dbf7d77897ad52cbef1db3..1ecb71f74ae7bacd272845421c56c9522227f485 --- 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 ():