mindspore.mint.empty
- mindspore.mint.empty(*size, dtype=None, device=None) Tensor [source]
Creates a tensor with uninitialized data, whose shape, dtype and device are described by the argument size, dtype and device respectively.
Warning
This is an experimental API that is subject to change or deletion.
- Parameters
size (Union[tuple[int], list[int], int]) – The specified shape of output tensor. Can be variable numbers of positive integers or tupled or list containing positive integers.
- Keyword Arguments
dtype (
mindspore.dtype
, optional) – The specified type of output tensor. If dtype isNone
, mindspore.float32 will be used. Default:None
.device (string, optional) – The specified device of the output tensor. Support
CPU
andAscend
. If device = None, mindspore.context.device_target will be used. DefaultNone
.
- Returns
Tensor, whose dtype and size are defined by input.
- Raises
TypeError – If size is neither an int nor a tuple or list of int.
- Supported Platforms:
Ascend
Examples
>>> import mindspore >>> from mindspore import mint >>> output = mint.empty((2, 3), dtype=mindspore.float32) >>> print(output) [[0. 0. 0.] [0. 0. 0.]]