Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output of Round is confusing #3755

Closed
tungld opened this issue Oct 5, 2021 · 2 comments
Closed

Output of Round is confusing #3755

tungld opened this issue Oct 5, 2021 · 2 comments
Labels
question Questions about ONNX

Comments

@tungld
Copy link

tungld commented Oct 5, 2021

Ask a Question

Question

In the definition of Round, it said it finds the nearest integer for each value, but according to the example

round([0.9]) = [1.0]
round([2.5]) = [2.0]
round([2.3]) = [2.0]
round([1.5]) = [2.0]
round([-4.5]) = [-4.0]

I am confused whether 2.0 is the nearest integer of 2.5 or 1.5. How was the nearest integer computed? Thanks!

Further information

Similar thing happened with the reference output of Round also: https://github.com/onnx/onnx/blob/master/docs/Operators.md#examples-110

  • Is this issue related to a specific model?
    Model name (e.g. mnist):
    Model opset (e.g. 7):

Notes

Any additional information, code snippets.

@tungld tungld added the question Questions about ONNX label Oct 5, 2021
@jcwchen
Copy link
Member

jcwchen commented Oct 5, 2021

Hi @tungld,
Actually the doc mentions this kind of scenario: In case of halfs, the rule is to round them to the nearest "even" integer. The output tensor has the same shape and type as the input. And this behavior is similar to numpy.around: https://numpy.org/doc/stable/reference/generated/numpy.around.html

@tungld
Copy link
Author

tungld commented Oct 5, 2021

Oh, I see, I was not aware of even. It would be helpful if we mention numpy.around in the doc. Thanks @jcwchen!

@tungld tungld closed this as completed Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions about ONNX
Projects
None yet
Development

No branches or pull requests

2 participants