onnx_array_api.graph_api#
GraphBuilder#
- class onnx_array_api.graph_api.GraphBuilder(target_opset_or_existing_proto: int | Dict[str, int] | ModelProto | FunctionProto | None = None, input_names: Sequence[str] | None = None, as_function: bool = False, optimization_options: OptimizationOptions | None = None, args: List[Any] | None = None, verbose: int = 0, ir_version: int | None = None)[source]#
- constant_folding()[source]#
Folds all constants. Constants are marked during the creation of the graph. There is no need to propagate this information.
- make_nodes(builder: GraphBuilder, input_names: List[str], output_names: List[str], prefix: str = '') str | List[str] [source]#
Appends all nodes and initializers from another builder. Handles the renaming of results. The content stored in ‘builder’ is modified inplace to avoid copying.
- Parameters:
builder – other builder
input_names – input names
output_names – output names
prefix – prefix all name from this builder
- Returns:
output names
- np(index: int | None = None, op_type: str | None = None, name: str | None = None) NodePattern [source]#
Returns an instance of
NodePattern
.
- remove_unused()[source]#
Simple function to remove unused nodes. It does not look into subgraphs and assumes there is none. Everything is done in one pass.
- update_attribute(pat: NodePattern, recursive: bool = False, **kwargs: Dict[str, Any]) int [source]#
Udates attributes for nodes matching the
- Parameters:
pat – returned by method
GraphBuilder.np()
recursive – walk through subgraph
kwargs – attributes to modify
- Returns:
number of modified nodes