Values

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.

opset

The Opset that this op belongs to.

name

The name of the op.

op_schema

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

Opset the function belongs to.

name

Name of the function.

function

Python function.

function_ir

Python code parsed as an irbuilder.IRFunction.

source

Source code used to generate the function.

kwargs

Additional properties used to construct a ModelProto.

op_schema

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.

to_model_proto(**kwargs)[source]

Converts the function into onnx.ModelProto.