Use type-directed translation of attribute values#923
Merged
gramalingam merged 19 commits intomainfrom Jul 26, 2023
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## main #923 +/- ##
==========================================
+ Coverage 76.80% 76.84% +0.04%
==========================================
Files 112 112
Lines 13552 13619 +67
Branches 1378 1386 +8
==========================================
+ Hits 10408 10466 +58
- Misses 2801 2805 +4
- Partials 343 348 +5
|
justinchuby
reviewed
Jul 26, 2023
Collaborator
Author
|
The doc-generation CI is failing. When I try to repro locally, sphinx fails (even earlier than the CI) for me with Any ideas? |
Collaborator
|
It started failing earlier this week. Looks like a dependency just updated and broke it |
justinchuby
approved these changes
Jul 26, 2023
| # The caller is responsible for omitting such attribute-values from the list of attributes | ||
| # in a NodeProto. | ||
| if val is None: | ||
| if attr_meta and attr_meta.required: |
Collaborator
There was a problem hiding this comment.
Should we test the error cases too?
Comment on lines
+435
to
+436
| # Utility to convert kwarg to ONNX AttributeProto: | ||
| def make_attr(key: str, value: Any) -> onnx.AttributeProto: |
Collaborator
There was a problem hiding this comment.
Suggested change
| # Utility to convert kwarg to ONNX AttributeProto: | |
| def make_attr(key: str, value: Any) -> onnx.AttributeProto: | |
| def make_attr(key: str, value: Any) -> onnx.AttributeProto: | |
| """Utility to convert kwarg to ONNX AttributeProto.""" |
| implicit_args = {k: _os_to_ort_value(v) for k, v in implicit_args.items()} | ||
|
|
||
| # Utility to convert kwarg to ONNX AttributeProto: | ||
| def make_attr(key: str, value: Any) -> onnx.AttributeProto: |
Collaborator
There was a problem hiding this comment.
Also lift the function to module and mark private to reduce nested functions?
|
|
||
| node = onnx.helper.make_node(schema.name, inputs, outputs, domain=schema.domain, **kwargs) | ||
| node = onnx.helper.make_node(schema.name, inputs, outputs, domain=schema.domain) | ||
| node.attribute.extend( |
Collaborator
There was a problem hiding this comment.
I wonder if we need to do the same for the torch_lib graph tracing evaluator.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use the attribute-type from opschema, when available, to handle attribute-values during translation, as well as in eager-mode.
This enables constructs like
Constant(value_ints=[]),Constant(value=0),Constant(value=[1,-1]).See #860 and #786