-
Notifications
You must be signed in to change notification settings - Fork 98
Fix unicode issue #2747
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?
Fix unicode issue #2747
Conversation
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
onnxscript/backend/onnx_export.py
Outdated
| try: | ||
| return s.decode("utf-8") | ||
| except UnicodeDecodeError: | ||
| return s.decode("latin1") # or "cp1252" or other fallback |
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.
I have seen cases where the string attributes iare used to store binary data (e.g. in the custom Tokenizer op, even though this is invalid onnx). Is this trying to address those cases? If so, I would simply preserve the b-string to avoid accidental modifications.
Related: onnx/ir-py#184
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.
I don't know. All I know is that this enabled me to convert a recent model (Word Fluency) into onnxscript so that I could see the control-flow structure of the model in a compact readable format. I don't mind alternatives if they allow me to do this.
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.
Right - that's the same model I looked at. Making a suggestion
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.
Can you try the current change?
Updated string decoding logic and attribute value check.
| value = _attribute_value(at) | ||
| if isinstance(value, str): | ||
| attributes.append((at.name, f"{value!r}")) | ||
| if isinstance(value, str, bytes): |
Check failure
Code scanning / lintrunner
PYLINT/E1121 Error
See too-many-function-args. To disable, use # pylint: disable=too-many-function-args
This copilot-suggested fix enabled converting a recent onnx model to onnxscript.