onnx.defs

Opset Version

onnx.defs.onnx_opset_version() int[source]

Return current opset for domain ai.onnx.

Operators and Functions Schemas

onnx.defs.has()

has_schema(*args, **kwargs) Overloaded function.

  1. has_schema(op_type: str, domain: str = ‘’) -> bool

  2. has_schema(op_type: str, max_inclusive_version: int, domain: str = ‘’) -> bool

onnx.defs.get_schema(*args, **kwargs)

Overloaded function.

  1. get_schema(op_type: str, max_inclusive_version: int, domain: str = ‘’) -> onnx.onnx_cpp2py_export.defs.OpSchema

Return the schema of the operator op_type and for a specific version.

  1. get_schema(op_type: str, domain: str = ‘’) -> onnx.onnx_cpp2py_export.defs.OpSchema

Return the schema of the operator op_type and for a specific version.

onnx.defs.get_all_schemas() list[onnx.onnx_cpp2py_export.defs.OpSchema]

Return the schema of all existing operators for the latest version.

onnx.defs.get_all_schemas_with_history() list[onnx.onnx_cpp2py_export.defs.OpSchema]

Return the schema of all existing operators and all versions.

onnx.defs.get_function_ops() list[OpSchema][source]

Return operators defined as functions.

onnx.defs.register_schema(schema: OpSchema) None[source]

Register a user provided OpSchema.

The function extends available operator set versions for the provided domain if necessary.

Parameters:

schema – The OpSchema to register.

onnx.defs.deregister_schema(op_type: str, version: int, domain: str) None

Deregister the specified OpSchema.

class OpSchema

class onnx.defs.OpSchema

Schema of an operator.

class AttrType

Members:

FLOAT

INT

STRING

TENSOR

GRAPH

FLOATS

INTS

STRINGS

TENSORS

GRAPHS

SPARSE_TENSOR

SPARSE_TENSORS

TYPE_PROTO

TYPE_PROTOS

FLOAT = <AttrType.FLOAT: 1>
FLOATS = <AttrType.FLOATS: 6>
GRAPH = <AttrType.GRAPH: 5>
GRAPHS = <AttrType.GRAPHS: 10>
INT = <AttrType.INT: 2>
INTS = <AttrType.INTS: 7>
SPARSE_TENSOR = <AttrType.SPARSE_TENSOR: 11>
SPARSE_TENSORS = <AttrType.SPARSE_TENSORS: 12>
STRING = <AttrType.STRING: 3>
STRINGS = <AttrType.STRINGS: 8>
TENSOR = <AttrType.TENSOR: 4>
TENSORS = <AttrType.TENSORS: 9>
TYPE_PROTO = <AttrType.TYPE_PROTO: 13>
TYPE_PROTOS = <AttrType.TYPE_PROTOS: 14>
property name
property value
class Attribute
property default_value
property description
property name
property required
property type
class DifferentiationCategory

Members:

Unknown

Differentiable

NonDifferentiable

Differentiable = <DifferentiationCategory.Differentiable: 1>
NonDifferentiable = <DifferentiationCategory.NonDifferentiable: 2>
Unknown = <DifferentiationCategory.Unknown: 0>
property name
property value
class FormalParameter
property description
property differentiation_category
property is_homogeneous
property min_arity
property name
property option
property type_str
property types
class FormalParameterOption

Members:

Single

Optional

Variadic

Optional = <FormalParameterOption.Optional: 1>
Single = <FormalParameterOption.Single: 0>
Variadic = <FormalParameterOption.Variadic: 2>
property name
property value
class SupportType

Members:

COMMON

EXPERIMENTAL

COMMON = <SupportType.COMMON: 0>
EXPERIMENTAL = <SupportType.EXPERIMENTAL: 1>
property name
property value
class TypeConstraintParam
property allowed_type_strs
property description
property type_param_str
property all_function_opset_versions
property attributes
property context_dependent_function_opset_versions
property deprecated
property doc
property domain
property file
property function_body
property function_opset_versions
get_context_dependent_function(self: onnx.onnx_cpp2py_export.defs.OpSchema, arg0: bytes, arg1: list[bytes]) bytes
get_context_dependent_function_with_opset_version(self: onnx.onnx_cpp2py_export.defs.OpSchema, arg0: int, arg1: bytes, arg2: list[bytes]) bytes
get_function_with_opset_version(self: onnx.onnx_cpp2py_export.defs.OpSchema, arg0: int) bytes
property has_context_dependent_function
property has_data_propagation_function
property has_function
property has_type_and_shape_inference_function
property inputs
static is_infinite(arg0: int) bool
property line
property max_input
property max_output
property min_input
property min_output
property name
property outputs
property since_version
property support_level
property type_constraints

Exceptions

class onnx.defs.SchemaError

Constants

Domains officially supported in onnx package.

from onnx.defs import (
    ONNX_DOMAIN,
    ONNX_ML_DOMAIN,
    AI_ONNX_PREVIEW_TRAINING_DOMAIN,
)
print(f"ONNX_DOMAIN={ONNX_DOMAIN!r}")
print(f"ONNX_ML_DOMAIN={ONNX_ML_DOMAIN!r}")
print(f"AI_ONNX_PREVIEW_TRAINING_DOMAIN={AI_ONNX_PREVIEW_TRAINING_DOMAIN!r}")
ONNX_DOMAIN=''
ONNX_ML_DOMAIN='ai.onnx.ml'
AI_ONNX_PREVIEW_TRAINING_DOMAIN='ai.onnx.preview.training'