提交 0b764cf2 编写于 作者: M Megvii Engine Team

docs(mge/functional): add docs for megengine.functional.full_like

GitOrigin-RevId: 391447e977e08a920deb05e6a7508d07a094784a
上级 f1411590
......@@ -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 ():
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册