-
Notifications
You must be signed in to change notification settings - Fork 8
Update from_onnx_text method #80
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: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found.
Additional details and impacted files@@ Coverage Diff @@
## main #80 +/- ##
==========================================
+ Coverage 73.48% 73.55% +0.06%
==========================================
Files 37 37
Lines 4507 4522 +15
Branches 906 913 +7
==========================================
+ Hits 3312 3326 +14
+ Misses 865 863 -2
- Partials 330 333 +3 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
238610e
to
0ce7885
Compare
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances ONNX text serialization by supporting a list of initializer tensors, exposes the to_onnx_text
method in the root namespace, adds tests for including/excluding initializers, and improves value mapping to traverse subgraphs.
- Change
from_onnx_text
to accept an iterable of initializer tensors and register them - Expose
to_onnx_text
at package root and add tests for both inclusion and exclusion of initializers - Update
create_value_mapping
to include values from subgraphs and initializers
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/onnx_ir/serde_test.py | Update expected IR version and add tests covering initializers |
src/onnx_ir/serde.py | Rename with_initializers to initializers and adjust logic |
src/onnx_ir/_convenience/init.py | Extend create_value_mapping to traverse subgraphs |
src/onnx_ir/init.py | Add to_onnx_text to exported symbols |
Comments suppressed due to low confidence (3)
src/onnx_ir/serde.py:209
- Update the
Raises
section to referenceinitializers
instead of the outdatedwith_initializers
parameter name.
ValueError: If a name in `with_initializers` does not exist in the model.
src/onnx_ir/_convenience/init.py:316
- The docstring should mention that initializers (
graph.initializers
) are also included in the mapping now.
The mapping includes values from subgraphs. Duplicated names are omitted,
src/onnx_ir/_convenience/init.py:329
- [nitpick] Avoid shadowing the built-in
input
function; consider renaming this loop variable to e.g.graph_input
orinp
.
for input in graph.inputs:
Signed-off-by: Justin Chu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the design logic of choosing between list and dict in initializers:
ir-py/src/onnx_ir/_protocols.py
Line 301 in ccdb051
initializers: MutableMapping[str, ValueProtocol] |
There is a bit of ambiguity with the naming of "initializers". Here these are more like "tensors that will initialize values" with matching names that we can use to find the set the const_value of corresponding values. In graph the initializers provided in Note that in graph we initialize with a list of values but when users access |
Do you have suggestions around naming? |
to_onnx_text
method in the root namespace.create_value_mapping
to include values from subgraphs.