
Contents
More
Starts an onnx model.
opset – main opset version
opsets – others opsets as a dictionary
ir_version – specify the ir_version as well
an instance ofonnx_array_api.light_api.OnnxGraph
A very simple model:
<<<
fromonnx_array_api.light_apiimportstartonx=start().vin("X").Neg().rename("Y").vout().to_onnx()print(onx)
>>>
ir_version:11graph{node{input:"X"output:"Y"op_type:"Neg"domain:""}name:"light_api"input{name:"X"type{tensor_type{elem_type:1shape{}}}}output{name:"Y"type{tensor_type{elem_type:1shape{}}}}}opset_import{domain:""version:22}
Another with operator Add:
<<<
fromonnx_array_api.light_apiimportstartonx=start().vin("X").vin("Y").bring("X","Y").Add().rename("Z").vout().to_onnx()print(onx)
>>>
ir_version:11graph{node{input:"X"input:"Y"output:"Z"op_type:"Add"domain:""}name:"light_api"input{name:"X"type{tensor_type{elem_type:1shape{}}}}input{name:"Y"type{tensor_type{elem_type:1shape{}}}}output{name:"Z"type{tensor_type{elem_type:1shape{}}}}}opset_import{domain:""version:22}
Starts a subgraph.:return: an instance ofonnx_array_api.light_api.OnnxGraph
..autofunction:: onnx_array_api.light_api.domain
Represents an input, an initializer, a node, an output,multiple variables.
parent – the graph containing the Variable
Creates a set of variable as an instance ofonnx_array_api.light_api.Vars.
Adds an initializer
value – constant tensor
name – input name
instance ofonnx_array_api.light_api.Var
Creates a set of variables as an instance ofonnx_array_api.light_api.Vars.*vars is added to the left,self is added to the right.
Creates a node with this Var as the first input.
op_type – operator type
inputs – others inputs
domain – domain
n_outputs – number of outputs
output_names – output names, if not specified, outputs are givenunique names
kwargs – node attributes
instance ofonnx_array_api.light_api.Var oronnx_array_api.light_api.Vars
Creates a set of variables as an instance ofonnx_array_api.light_api.Vars.*vars is added to the right,self is added to the left.
Creates the onnx graph.
Retrieves another variable than this one.
name – name of the variable
instance ofonnx_array_api.light_api.Var
Contains every piece needed to create an onnx model in a single instructions.This API is meant to be light and allows the description of a graph.
opset – main opset version
opsets – other opsets as a dictionary
ir_version – to specify an ir_version
is_function – aonnx.ModelProto or aonnx.FunctionProto
Adds an initializer
value – constant tensor
name – input name
instance ofonnx_array_api.light_api.Var
Adds an initializer to the graph.
Adds an input to the graph.
name – input name
elem_type – element type (the input is assumed to be a tensor)
shape – shape
an instance of ValueInfoProto
Creates a node.
op_type – operator type
inputs – others inputs
domain – domain
n_outputs – number of outputs
output_names – output names, if not specified, outputs are givenunique names
kwargs – node attributes
NodeProto
Adds an output to the graph.
name – input name
elem_type – element type (the input is assumed to be a tensor)
shape – shape
an instance of ValueInfoProto
If the checker fails, tryshape=[].
Renames a variable. The renaming does notchange anything but is stored in a container.
old_name – old name
new_name – new name
Converts the graph into an ONNX graph.
Some names were renamed. If name is one of them, the functionreturns the new name.
Represents an input, an initializer, a node, an output.
parent – graph the variable belongs to
name – input name
elem_type – element_type
shape – shape
Creates a set of variable as an instance ofonnx_array_api.light_api.Vars.
Adds an initializer
value – constant tensor
name – input name
instance ofonnx_array_api.light_api.Var
Creates a set of variables as an instance ofonnx_array_api.light_api.Vars.*vars is added to the left,self is added to the right.
Creates a node with this Var as the first input.
op_type – operator type
inputs – others inputs
domain – domain
n_outputs – number of outputs
output_names – output names, if not specified, outputs are givenunique names
kwargs – node attributes
instance ofonnx_array_api.light_api.Var oronnx_array_api.light_api.Vars
Returns the name of the variable or the new name if it was renamed.
Creates a set of variables as an instance ofonnx_array_api.light_api.Vars.*vars is added to the right,self is added to the left.
Creates the onnx graph.
Retrieves another variable than this one.
name – name of the variable
instance ofonnx_array_api.light_api.Var
Represents multiple Var.
parent – graph the variable belongs to
vars – list of names or variables
Creates a set of variable as an instance ofonnx_array_api.light_api.Vars.
Adds an initializer
value – constant tensor
name – input name
instance ofonnx_array_api.light_api.Var
Creates a set of variables as an instance ofonnx_array_api.light_api.Vars.*vars is added to the left,self is added to the right.
Creates a node with this Var as the first input.
op_type – operator type
inputs – others inputs
domain – domain
n_outputs – number of outputs
output_names – output names, if not specified, outputs are givenunique names
kwargs – node attributes
instance ofonnx_array_api.light_api.Var oronnx_array_api.light_api.Vars
Creates a set of variables as an instance ofonnx_array_api.light_api.Vars.*vars is added to the right,self is added to the left.
Creates the onnx graph.
Retrieves another variable than this one.
name – name of the variable
instance ofonnx_array_api.light_api.Var