Skip to content

Commit f7da1e0

Browse files
committed
message
Signed-off-by: Justin Chu <[email protected]>
1 parent a27d866 commit f7da1e0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/onnx_ir/serde.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ def _deserialize_attribute(
11491149
# Even though onnx.ai/onnx/repo-docs/IR.html#attributes requires the attribute
11501150
# for strings to be utf-8 encoded bytes, custom ops may still store arbitrary data there
11511151
logger.warning(
1152-
"Attribute '%s' contains invalid UTF-8 bytes. ONNX spec requires string attributes "
1152+
"Attribute %r contains invalid UTF-8 bytes. ONNX spec requires string attributes "
11531153
"to be UTF-8 encoded so the model is invalid. We will skip decoding the attribute and "
11541154
"use the bytes as attribute value",
11551155
name,
@@ -1807,6 +1807,12 @@ def _fill_in_value_for_attribute(
18071807
if type(value) is bytes:
18081808
# Even though onnx.ai/onnx/repo-docs/IR.html#attributes requires the attribute
18091809
# for strings to be utf-8 encoded bytes, custom ops may still store arbitrary data there
1810+
logger.warning(
1811+
"Value in attribute %r should be a string but is instead bytes. ONNX "
1812+
"spec requires string attributes to be UTF-8 encoded so the model is invalid. "
1813+
"We will skip encoding the attribute and use the bytes as attribute value",
1814+
attribute_proto.name,
1815+
)
18101816
attribute_proto.s = value
18111817
else:
18121818
attribute_proto.s = value.encode("utf-8")

0 commit comments

Comments
 (0)