Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion onnxscript/backend/onnx_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ def _translate_value_info(value_info: ValueInfoProto) -> str:

def _to_str(s):
if isinstance(s, bytes):
return s.decode("utf-8")
try:
return s.decode("utf-8")
except UnicodeDecodeError:
return s.decode("latin1") # or "cp1252" or other fallback
Copy link
Collaborator

@justinchuby justinchuby Dec 27, 2025

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

Copy link
Collaborator Author

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.

Copy link
Collaborator

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

Copy link
Collaborator

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?

return s


Expand Down
Loading