Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/onnx/printer.py: 29%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# Copyright (c) ONNX Project Contributors
2#
3# SPDX-License-Identifier: Apache-2.0
4from __future__ import annotations
6import onnx
7import onnx.onnx_cpp2py_export.printer as C # noqa: N812
10def to_text(
11 proto: onnx.ModelProto | onnx.FunctionProto | onnx.GraphProto | onnx.NodeProto,
12) -> str:
13 if isinstance(proto, onnx.ModelProto):
14 return C.model_to_text(proto.SerializeToString())
15 if isinstance(proto, onnx.FunctionProto):
16 return C.function_to_text(proto.SerializeToString())
17 if isinstance(proto, onnx.GraphProto):
18 return C.graph_to_text(proto.SerializeToString())
19 if isinstance(proto, onnx.NodeProto):
20 return C.node_to_text(proto.SerializeToString())
21 raise TypeError("Unsupported argument type.")