mindspore.ops.Rint

class mindspore.ops.Rint[source]

Returns an integer that is closest to input_x element-wise.

Inputs:
  • input_x (Tensor) - Input tensor of any dimension, which must be one of the following types: float16, float32, float64.

Outputs:

Tensor, has the same shape and type as input_x.

Raises

TypeError – If dtype of input_x is not in [float16, float32, float64].

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> input_x = Tensor(np.array([-1.6, -0.1, 1.5, 2.0]), mindspore.float32)
>>> op = ops.Rint()
>>> output = op(input_x)
>>> print(output)
[-2.  0.  2.  2.]
>>> input_x = Tensor(np.array([[-2.0, -1.9, -1.8, -1.7, -1.6],
...                            [-2.0, -1.9, -1.8, -1.7, -1.6]]), mindspore.float32)
>>> output = op(input_x)
>>> print(output)
[[-2. -2. -2. -2. -2.]
 [-2. -2. -2. -2. -2.]]