yobx.translate#

Top-level helpers#

yobx.translate.translate(proto: ModelProto, single_line: bool = False, api: str = 'onnx') str[source]#

Translates an ONNX proto into Python code that recreates the ONNX graph.

Parameters:
  • proto – model to translate

  • single_line – as a single line or not

  • api – API to export into, default is "onnx" which generates code using onnx.helper (handled by InnerEmitter), "onnx-short" replaces large initializers with random values (handled by InnerEmitterShortInitializer), "onnx-compact" generates a compact single-expression form (handled by InnerEmitterCompact), "light" generates code for the light API, "builder" generates code for the GraphBuilder, "mermaid" generates a Mermaid flowchart string (handled by MermaidEmitter)

Returns:

code as a string

yobx.translate.translate_header(api: str = 'onnx')[source]#

Returns the necessary imports header for each api.