oneflow.round¶
-
oneflow.
round
()¶ This operator rounds the value of Blob to the nearest integer.
Note
This function implements the “round half to even” to break ties when a number is equidistant from two integers (e.g. round(2.5) is 2).
- Parameters
input (oneflow.Tensor) – A Tensor
- Returns
The result Tensor
- Return type
For example:
>>> import oneflow as flow >>> import numpy as np >>> x1 = flow.tensor(np.array([1.49999, 1.500001, 2.7]).astype(np.float32)) >>> out1 = flow.round(x1) >>> out1.numpy() array([1., 2., 3.], dtype=float32) >>> x2 = flow.tensor(np.array([2.499999, 7.5000001, 5.3, 6.8]).astype(np.float32)) >>> out2 = flow.round(x2) >>> out2.numpy() array([2., 8., 5., 7.], dtype=float32)