MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / full_like

Function full_like

imperative/python/megengine/functional/tensor.py:517–537  ·  view source on GitHub ↗

r"""Returns a tensor filled with given value with the same shape as input tensor. Args: inp(Tensor): input tensor from which to derive the output tensor shape. value(Scalar): fill value. Return: a tensor having the same shape as input tensor and where every element

(inp: Tensor, value: Union[int, float])

Source from the content-addressed store, hash-verified

515
516
517def full_like(inp: Tensor, value: Union[int, float]) -> Tensor:
518 r"""Returns a tensor filled with given value with the same shape as input tensor.
519
520 Args:
521 inp(Tensor): input tensor from which to derive the output tensor shape.
522 value(Scalar): fill value.
523
524 Return:
525 a tensor having the same shape as input tensor and where every element is equal to fill value.
526
527 Examples:
528 >>> x = F.arange(6, dtype='int32').reshape(2, 3)
529 >>> F.full_like(x, 2)
530 Tensor([[2 2 2]
531 [2 2 2]], dtype=int32, device=xpux:0)
532 """
533 op = builtin.FillLike(value=value)
534 (rst,) = apply(op, inp)
535 # rst.format = inp.format
536 # see jira:MGE-4505
537 return rst
538
539
540# manipulation functions

Callers 5

_get_parameterMethod · 0.85
backwardMethod · 0.85
backwardMethod · 0.85
zeros_likeFunction · 0.85
ones_likeFunction · 0.85

Calls 1

applyFunction · 0.50

Tested by

no test coverage detected