-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Support node labels in parser and printer #6349
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
Conversation
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6349 +/- ##
==========================================
- Coverage 57.23% 57.23% -0.01%
==========================================
Files 507 507
Lines 31406 31406
Branches 4690 4690
==========================================
- Hits 17976 17975 -1
Misses 12575 12575
- Partials 855 856 +1 ☔ View full report in Codecov by Sentry. |
Alternatively putting them at the back:
Or does this syntax support line breaks, so
is valid? |
Yes ... that is precisely the choice/tradeoff discussed between (a) and (b). Option (b) avoids it, at the cost of including any extra blanks before or after the label as part of the label. (Though we could skip that, but seems a bit complicated). Yes, line breaks can be used. Putting the labels at the end: hmmm. It has the advantage you mention. But it seems less natural (convention typically puts labels before the statement; and, with if/while this would push the label to appear after the entire if/while body). I am inclined to leave it as is (visualization tools can always choose to present it differently, with alignment/omission etc. being supported as pretty-printing options). |
I see. "some node" is a valid identifier. I missed that part. |
I am unclear what your preference is. I am planning to extend the PR to allow |
I think it would be more straightforward to just assume a valid identifier so that it is consistent across. |
Sorry I see the trade off now: node names may not be a valid identifier… edit: but still users can still write [ "6" ], which fits well with the fact that node names are strings. I personally feel that option (a) is clean and nice. |
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
Ok, I will leave this as is (using option 1). |
### Description 1) Adds support for node label in parser and printer 2) Adds some status-checks that were missed in recent addition to support invalid identifiers. Node labels are now supported with the following syntax: ``` [a_node_label] y = MatMul (x, w) ``` However, we have a couple of options to choose from here: (a) The ONNX spec says that the node label must be a valid identifier. So, we can allow for a valid identifier between the `[...]`, relying on a quoted string inside if the user wants to use something that is not a valid identifier. (b) Alternatively, since `[` and `]` act as end-markers, like quotes, we can allow any string in-between, that is taken to be the node label. (Users will need to use an escape backslash if they want `]` in the label.) Option (b) is better if users want to use non-identifier labels, eg., numbers, etc. I am inclined to go with (b), even though it is extra code. However, it won't be friendly to the use of white-space inside if users want to use identifier labels. Eg., `[ mylabel ]` will include the blank spaces in the label. The implementation currently does only (a), which is simpler. --------- Signed-off-by: Ganesan Ramalingam <grama@microsoft.com> Co-authored-by: Andreas Fehlner <fehlner@arcor.de> Signed-off-by: Linsho Kaku <linsho@preferred.jp>
Description
Node labels are now supported with the following syntax:
However, we have a couple of options to choose from here:
(a) The ONNX spec says that the node label must be a valid identifier. So, we can allow for a valid identifier between the
[...]
, relying on a quoted string inside if the user wants to use something that is not a valid identifier.(b) Alternatively, since
[
and]
act as end-markers, like quotes, we can allow any string in-between, that is taken to be the node label. (Users will need to use an escape backslash if they want]
in the label.)Option (b) is better if users want to use non-identifier labels, eg., numbers, etc. I am inclined to go with (b), even though it is extra code. However, it won't be friendly to the use of white-space inside if users want to use identifier labels. Eg.,
[ mylabel ]
will include the blank spaces in the label.The implementation currently does only (a), which is simpler.