onnx_ir.schemasΒΆ
The onnx_ir.schemas module provides classes for representing operator signatures and their parameters. These classes are useful for introspecting operator definitions and validating operator usage.
OpSignatureΒΆ
The OpSignature class represents the schema for an ONNX operator, including its inputs, outputs, and attributes.
- class onnx_ir.schemas.OpSignature(domain, name, overload, params, outputs, since_version=1)[source]ΒΆ
Schema for an operator.
- Parameters:
- paramsΒΆ
Input parameters. When the op is an ONNX function definition, the order is according to the function signature. This mean we can interleave ONNX inputs and ONNX attributes in the list.
- outputsΒΆ
Output parameters.
- property attributes: Sequence[AttributeParameter]ΒΆ
Returns the attribute parameters.
- classmethod from_op_schema(op_schema)[source]ΒΆ
Produce an OpSignature from an ONNX OpSchema.
- Parameters:
op_schema (OpSchema)
- Return type:
- get(name, default=None)[source]ΒΆ
- Parameters:
name (str)
default (Parameter | AttributeParameter | None)
- Return type:
Parameter | AttributeParameter | None
- params: Sequence[Parameter | AttributeParameter]ΒΆ
- params_map: Mapping[str, Parameter | AttributeParameter]ΒΆ
ParameterΒΆ
The Parameter class represents a formal input parameter of an operator.
- class onnx_ir.schemas.Parameter(name, type_constraint, required, variadic, homogeneous=True, min_arity=1, default=_EMPTY_DEFAULT)[source]ΒΆ
A formal parameter of an operator.
- Parameters:
- is_param()[source]ΒΆ
This parameter is an ONNX input or output parameter, as opposed to an ONNX attribute parameter.
- Return type:
- type_constraint: TypeConstraintParamΒΆ
AttributeParameterΒΆ
The AttributeParameter class represents an attribute parameter in the operator signature.
- class onnx_ir.schemas.AttributeParameter(name, type, required, default=None)[source]ΒΆ
A parameter in the function signature that represents an ONNX attribute.
- Parameters:
name (str)
type (AttributeType)
required (bool)
default (Attr | None)
- is_attribute()[source]ΒΆ
This parameter is an ONNX attribute parameter, as opposed to an ONNX input or output parameter.
- Return type:
- type: AttributeTypeΒΆ
TypeConstraintParamΒΆ
The TypeConstraintParam class represents type constraints for parameters, specifying which types are allowed.