Render

systemds.onnx_systemds.render.gen_graph_functions(env: jinja2.environment.Environment, main_graph: onnx.onnx_ONNX_REL_1_7_ml_pb2.GraphProto) -> ([<class 'str'>], <class 'str'>, [<class 'str'>])

Traverses the node tree of the onnx-graph structure and generates a script string for each node, as well as a string for the required imports together with all functions of sub-graphs. The resulting lists are correctly ordered for inserting them in the dml script.

Parameters
  • env – Jinja environment to load the template files

  • main_graph – the onnx graph for which the script shall be generated

Returns

Tuple (imports, main function, sub-graph functions)

systemds.onnx_systemds.render.gen_model_header(env: jinja2.environment.Environment, model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto) → str

Generates the header of the script for the given model

Parameters
  • env – Jinja environment to load the template files

  • model – the onnx model for which the header shall be generated

Returns

the generated header

systemds.onnx_systemds.render.gen_node_script(env: jinja2.environment.Environment, graph: onnx.onnx_ONNX_REL_1_7_ml_pb2.GraphProto, node: onnx.onnx_ONNX_REL_1_7_ml_pb2.NodeProto) → systemds.onnx_systemds.operator_gen.GeneratedScriptPart

Generates a dml script snippet, the required imports and sub-graphs for the given node

Parameters
  • env – Jinja environment to load the template files

  • graph – the onnx graph for which the script shall be generated

  • node – the node for which the dml snippet shall be generated

Returns

The generated script-part

systemds.onnx_systemds.render.gen_script(model: onnx.onnx_ONNX_REL_1_7_ml_pb2.ModelProto, output_file: str = None) → str

Generate the dml script for the given model and return it. If an output_file is given, the script is also written to a file.

Parameters
  • model – the model for which the dml script shall be generated

  • output_file – (optional) the file to which the script shall be written

Returns

the generated dml-script

systemds.onnx_systemds.render.render_function(env: jinja2.environment.Environment, graph: onnx.onnx_ONNX_REL_1_7_ml_pb2.GraphProto, generated_node_scripts: [<class 'str'>]) → str

Generates the dml function for the given graph and inserts the ‘generated_node_scripts’ in the function-body.

Parameters
  • env – Jinja environment to load the template files

  • graph – the graph for which the function shall be generated

  • generated_node_scripts – the node scripts in correct order for the function-body

Returns

the generated function