-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Getting onnx to treat inf/-inf
as float literals.
#5528
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
Getting onnx to treat inf/-inf
as float literals.
#5528
Conversation
3d28307
to
e0f192f
Compare
32bd959
to
cc43d77
Compare
D:\a\1\s\onnx\defs\parser.cc(72,7): warning C4101: 'e': unreferenced local variable [D:\a\1\s.setuptools-cmake-build\onnx.vcxproj] |
9b12086
to
697e217
Compare
@gramalingam it seems like the parser treats any attribute value starting with an |
Hmmm, that's a good point. The tensor/proto is not a concern, because that is a fixed list of type-identifiers that does not clash with inf/nan. The concern is the graph-name, specifically if users want to give a graph-attribute graph a name like "inf". I think checking for a valid float alphabetic literal is a reasonable choice. This does not ban the use of "inf" etc. as a valid name in other places (like a tensor variable name), it only restricts its use as a graph-name for a graph-attribute. Given that we are already restricting the graph-identifier (it can't use type names like "float"), this may be okay. Further, we can provide an "escape mechanism" to allow users who really want to produce a graph with name "inf" ... users can write attributes with or without type-annotation: e.g., they can write "mygraph : graph = ..." or "mygraph = ...". It is only in the latter situation that we need to make a guess. In the former case, we can use the type-annotation to guide the parser (which doesn't exist currently, but we can add it easily enough). Does that sound reasonable? Thanks! |
inf/-inf
as float literals.inf/-inf
as float literals.
36e6ca4
to
1e7d0b0
Compare
I believe everything has been addressed. Please take another look. Thanks for the reviews! |
Head branch was pushed to by a user without write access
Signed-off-by: Clif Houck <me@clifhouck.com>
Signed-off-by: Clif Houck <me@clifhouck.com>
Signed-off-by: Clif Houck <me@clifhouck.com>
Signed-off-by: Clif Houck <me@clifhouck.com>
Signed-off-by: Clif Houck <me@clifhouck.com>
Signed-off-by: Clif Houck <me@clifhouck.com>
Signed-off-by: Clif Houck <me@clifhouck.com>
Signed-off-by: Clif Houck <me@clifhouck.com>
Signed-off-by: Clif Houck <me@clifhouck.com>
Signed-off-by: Clif Houck <me@clifhouck.com>
Signed-off-by: Clif Houck <me@clifhouck.com>
Signed-off-by: Clif Houck <me@clifhouck.com>
Signed-off-by: Clif Houck <me@clifhouck.com>
Signed-off-by: Clif Houck <me@clifhouck.com>
03047f1
to
5d5e1a9
Compare
Description
onnx seems to ignore certain possibilities when it comes to otherwise valid IEEE float values. So far this change just adds functionality to the parser to recognize
inf
or-inf
as floats. However, this seems to point towards more issues. Should onnx recognize any string parse-able bystd::stof
as a float literal?Motivation and Context
The current state of this PR does address #5102, although not in a very elegant fashion.