Skip to content
Open
Changes from all commits
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

return s


Expand Down
Loading