mindspore.ops.round

mindspore.ops.round(input)[source]

Returns half to even of a tensor element-wise.

\[out_i \approx input_i\]
Parameters

input (Tensor) – The input tensor.

Returns

Tensor, has the same shape and type as the input.

Raises

TypeError – If input is not a Tensor.

Supported Platforms:

Ascend GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> input = Tensor(np.array([0.8, 1.5, 2.3, 2.5, -4.5]), mindspore.float32)
>>> output = ops.round(input)
>>> print(output)
[ 1.  2.  2.  2. -4.]