megengine.functional.full#

full(shape, value, *, dtype=None, device=None)[source]#

Returns a new tensor having a specified shape and filled with given value.

Parameters:
  • shape (int...) – output tensor shape.

  • value (Scalar) – fill value.

Keyword Arguments:
  • dtype (Tensor.dtype, optional) – output tensor data type. If dtype is None, the output tensor data type must be inferred from value. If the value is an int, the output tensor data type must be the default integer data type. If the value is a float, the output tensor data type must be the default floating-point data type. If the value is a bool, the output tensor must have boolean data type.

  • device (Tensor.device, optional) – device on which to place the created tensor.

Return type:

Tensor

Returns:

a tensor where every element is equal to value.

Examples

>>> F.full((2, 3), 6)
Tensor([[6 6 6]
 [6 6 6]], dtype=int32, device=xpux:0)