mindspore.mint.empty
- mindspore.mint.empty(*size, *, dtype=None, device=None, pin_memory=False) Tensor [source]
Creates a tensor with uninitialized data, whose shape, dtype and device are described by the argument size, dtype and device respectively. If pin_memory is True, the tensor will be allocated in pinned memory.
- Parameters
size (Union[tuple[int], list[int], int]) – The specified shape of output tensor. Can be variable numbers of positive integers or tuple 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. In PyNative mode,
"Ascend"
,"npu"
,"cpu"
and"CPU"
are supported. In graph mode O0,"Ascend"
and"npu"
are supported. If device = None, mindspore.context.device_target will be used. DefaultNone
.pin_memory (bool, optional) – If set pin_memory to True, the tensor will be allocated in pinned memory, and device should be
"cpu"
or"CPU"
. DefaultFalse
.
- Returns
Tensor, whose shape, dtype and device are defined by input.
- Raises
TypeError – If size is neither an int nor a tuple or list of int.
RuntimeError – If pin_memory is True, and device is neither
"cpu"
nor"CPU"
.
- 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.]]