-
Notifications
You must be signed in to change notification settings - Fork 101
Raise version converter error when function attribute is RefAttr #2806
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
base: main
Are you sure you want to change the base?
Raise version converter error when function attribute is RefAttr #2806
Conversation
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
Adds a guardrail in the ONNX opset version converter to explicitly reject functions containing RefAttr (reference attributes), since the converter/adapters don’t currently support them, and adds a regression test to ensure an error is raised.
Changes:
- Add validation in
visit_graph_or_functionto raiseVersionConverterErrorwhen an ONNX-domain node contains aRefAttr. - Add a unit test that builds a model with a function containing a node with a
RefAttrand asserts conversion fails with the expected message.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
onnxscript/version_converter/_version_converter.py |
Adds a hard-fail validation for RefAttr on nodes processed by the version converter. |
onnxscript/version_converter/_version_converter_test.py |
Adds a unit test covering the new RefAttr rejection behavior. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| ir.passes.PassError, | ||
| ) | ||
| ) as ctx: | ||
| version_converter.convert_version(model, target_version=target_version) |
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.
It is an issue that PassError is raised. I realized this in the shape inferencer as well. I think we should find a way to move the main logic out of the pass, and make the pass a simple wrapper around the logic so VersionConverterError can be properly raised by convert_version
| version_converter.convert_version(model, target_version=target_version) | ||
| # Check the error message, unwrapping PassError if needed | ||
| error = ctx.exception | ||
| if isinstance(error, ir.passes.PassError) and error.__cause__ is not None: |
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.
We should use assertRegex, after the error is properly raised
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2806 +/- ##
==========================================
+ Coverage 70.50% 70.52% +0.01%
==========================================
Files 228 228
Lines 27211 27136 -75
Branches 2737 2728 -9
==========================================
- Hits 19186 19137 -49
+ Misses 7090 7065 -25
+ Partials 935 934 -1 ☔ View full report in Codecov by Sentry. |
Co-authored-by: Justin Chu <justinchuby@users.noreply.github.com>
Regarding the concern from #2791 (comment), this PR specifically raises when function has RefAttr.
This pull request adds a new validation to the version converter to ensure nodes with reference attributes (
RefAttr) are not supported, and introduces a corresponding unit test to verify that the version converter raises an error in such cases.Validation for unsupported reference attributes:
visit_graph_or_functioninonnxscript/version_converter/_version_converter.pyto raise aVersionConverterErrorif any node has a reference attribute (RefAttr), as these are not currently supported by the version converter.Testing and error handling:
test_version_convert_raises_on_function_node_with_ref_attributeinonnxscript/version_converter/_version_converter_test.pyto ensure that converting a model containing a function node with a reference attribute raises the appropriate error and includes a clear message.