mindspore.Tensor.int

Tensor.int()[source]

Converts input tensor dtype to int32. If the value in tensor is float or half, the decimal will be discarded.

Returns

Tensor, converted to the int32 dtype.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import numpy as np
>>> import mindspore
>>> from mindspore import Tensor
>>> input_x = Tensor(np.ones([2,2]), mindspore.float32)
>>> output = input_x.int()
>>> print(output.dtype)
Int32