class onnxscript.values.Opset(domain: str, version: int)[source]

Represents an ONNX Opset, which consists of a domain name, a version.

It also contains a set of operations. This represents an Opset defined in the ONNX schema registry and the operations are retrieved from the ONNX schema registry. It also stores function definitions created for ops in the corresponding Opset.

Only a single instance of Opset is created for a given (domain, version) pair.

class onnxscript.values.Op(opset: Opset, opname: str, op_schema: OpSchema | None = None)[source]

Represents an ONNX op instance (for example, the MatMul op from ONNX opset version 13).

It belongs to a particular Opset and has a name.


The Opset that this op belongs to.


The name of the op.


The ONNX OpSchema for the op.

has_schema() bool[source]

Returns True if this op has an OpSchema.

param_schemas() tuple[ParamSchema, ...] | None[source]

Returns the parameter schemas for this op, if it has one.

class onnxscript.values.OnnxFunction(opset: Opset | None, pyfun: LambdaType, irfun: IRFunction, source: str, kwargs: dict[str, Any])[source]

Represents an ONNX op for which a function-body has been defined in onnxscript.


Opset the function belongs to.


Name of the function.


Python function.


Python code parsed as an irbuilder.IRFunction.


Source code used to generate the function.


Additional properties used to construct a ModelProto.


Generated ONNX OpSchema for this op.

property op_schema: OpSchema | None

Construct an OpSchema from function_ir.

property opname: str

Deprecated since version 0.1.

Deprecated and will be removed in version 0.3. Please use ‘.name’ instead.

param_schemas() tuple[ParamSchema, ...][source]

Returns the parameter schemas of this function.

to_function_proto() FunctionProto[source]

Converts the function into onnx.FunctionProto.


Converts the function into onnx.ModelProto.