提交 7138e4fd 编写于 作者: M Megvii Engine Team

feat(docs): add docs for megengine.functional.full

GitOrigin-RevId: 8428a0c9a90b92570dc0f35f03d7cf79ec284c2a
上级 0b4a7679
......@@ -96,9 +96,34 @@ def eye(N, M=None, *, dtype="float32", device: Optional[CompNode] = None) -> Ten
def full(shape, value, dtype="float32", device=None) -> Tensor:
r"""
Creates a tensor of shape ``shape`` filled with ``value``.
:param shape: a list, tuple or integer defining the shape of the output tensor.
:param value: the value to fill the output tensor with.
:param dtype: the desired data type of the output tensor. Default: ``float32``.
:param device: the desired device of the output tensor. Default: if ``None``, use the default device(see ``megengine.get_default_device()``).
:return: output tensor.
Examples:
.. testcode::
import numpy as np
import megengine.functional as F
out = F.full([2,3], 1.5)
print(out.numpy())
Outputs:
.. testoutput::
[[1.5 1.5 1.5]
[1.5 1.5 1.5]]
"""
Returns a tensor with given shape and value.
"""
if isinstance(shape, int):
shape = (shape,)
if device is None:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册