yobx.helpers._einsum._onnx_utils#

Minimal ONNX graph utilities for the einsum decomposition package.

yobx.helpers._einsum._onnx_utils.onnx_remove_node_unused(model: ModelProto) ModelProto[source]#

Removes nodes from model whose outputs are never consumed (dead code).

Walks the graph backwards from the declared outputs and marks every node that contributes to at least one output. Nodes that are not marked are dropped. Initializers that are no longer referenced are also removed.

Parameters:

model – input ONNX model

Returns:

new onnx.ModelProto without unreachable nodes