Skip to content

Commit

Permalink
Include the ".onnxtext" extension in supported serialization format (#…
Browse files Browse the repository at this point in the history
…6051)

Usage seen in
https://github.com/onnx/onnx-mlir/blob/5ef91c1be51eb578e61d2ae3c05fa821297a8ee2/test/mlir/onnx/parse/fun_model_test.onnxtext.
(onnx/onnx-mlir#2262). I added the `.onnxtext`
extension to be a known extension for the serializer.

---------

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
  • Loading branch information
justinchuby committed Apr 4, 2024
1 parent fa0b899 commit 1a6aa6a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion onnx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
# Supported model formats that can be loaded from and saved to
# The literals are formats with built-in support. But we also allow users to
# register their own formats. So we allow str as well.
_SupportedFormat = Union[Literal["protobuf", "textproto"], str]
_SupportedFormat = Union[Literal["protobuf", "textproto", "onnxtxt", "json"], str]
# Default serialization format
_DEFAULT_FORMAT = "protobuf"

Expand Down
2 changes: 1 addition & 1 deletion onnx/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ class _TextualSerializer(ProtoSerializer):
"""Serialize and deserialize the ONNX textual representation."""

supported_format = "onnxtxt"
file_extensions = frozenset({".onnxtxt"})
file_extensions = frozenset({".onnxtxt", ".onnxtext"})

def serialize_proto(self, proto: _Proto) -> bytes:
text = onnx.printer.to_text(proto) # type: ignore[arg-type]
Expand Down

0 comments on commit 1a6aa6a

Please sign in to comment.