mindspore.ops.FillV2

View Source On Gitee
class mindspore.ops.FillV2[source]

Creates a tensor with shape described by shape and fills it with values in value .

Inputs:
  • shape (Union[Tuple[int], Tensor[int]]) - 1-D Tensor or Tuple, specify the shape of output tensor. Its dtype must be int32 or int64.

  • value (Tensor) - A 0-D Tensor, the value to fill the output tensor y .

Outputs:
  • y (Tensor) - A tensor, its shape and value are described above.

Raises
  • TypeError – If shape is not a 1-D tensor or tuple.

  • TypeError – If the data type of shape is not int32 or int64.

  • ValueError – If value is not a 0-D Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> from mindspore import Tensor, ops
>>> fillV2 = ops.FillV2()
>>> output = fillV2(Tensor([2, 3], mindspore.int32), Tensor(1, mindspore.float32))
>>> print(output)
[[1. 1. 1.]
 [1. 1. 1.]]
>>> output = fillV2(Tensor([3, 3], mindspore.int64), Tensor(0, mindspore.int32))
>>> print(output)
[[0 0 0]
 [0 0 0]
 [0 0 0]]