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(op_type: str, domain: str = ‘’) -> bool has_schema(op_type: str, max_inclusive_version: int, domain: str = ‘’) -> bool

onnx.defs.get_schema(op_type: str, max_inclusive_version: int, domain: str = '') onnx.onnx_cpp2py_export.defs.OpSchema
onnx.defs.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(value)
FLOAT = 1
FLOATS = 6
GRAPH = 5
GRAPHS = 10
INT = 2
INTS = 7
SPARSE_TENSOR = 11
SPARSE_TENSORS = 12
STRING = 3
STRINGS = 8
TENSOR = 4
TENSORS = 9
TYPE_PROTO = 13
TYPE_PROTOS = 14
class Attribute
property default_value
property description

(self) -> str

property name

(self) -> str

property required

(self) -> bool

property type

(self) -> onnx.onnx_cpp2py_export.defs.OpSchema.AttrType

class DifferentiationCategory(value)
Differentiable = 1
NonDifferentiable = 2
Unknown = 0
class FormalParameter
property description

(self) -> str

property differentiation_category

(self) -> onnx.onnx_cpp2py_export.defs.OpSchema.DifferentiationCategory

property is_homogeneous

(self) -> bool

property min_arity

(self) -> int

property name

(self) -> str

property option

(self) -> onnx.onnx_cpp2py_export.defs.OpSchema.FormalParameterOption

property type_str

(self) -> str

property types

(self) -> std::unordered_set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*>, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*> >

class FormalParameterOption(value)
Optional = 1
Single = 0
Variadic = 2
class SupportType(value)
COMMON = 0
EXPERIMENTAL = 1
class TypeConstraintParam
property allowed_type_strs

(self) -> list[str]

property description

(self) -> str

property type_param_str

(self) -> str

property all_function_opset_versions

(self) -> list[int]

property attributes

(self) -> dict[str, onnx.onnx_cpp2py_export.defs.OpSchema.Attribute]

property context_dependent_function_opset_versions

(self) -> list[int]

property deprecated

(self) -> bool

property doc

(self) -> str

property domain

(self) -> str

property file

(self) -> str

property function_body
property function_opset_versions

(self) -> list[int]

get_context_dependent_function
get_context_dependent_function_with_opset_version
get_function_with_opset_version
get_type_and_shape_inference_function
property has_context_dependent_function

(self) -> bool

property has_data_propagation_function

(self) -> bool

property has_function

(self) -> bool

property has_type_and_shape_inference_function

(self) -> bool

property inputs

(self) -> list[onnx.onnx_cpp2py_export.defs.OpSchema.FormalParameter]

is_infinite = <nanobind.nb_func object>
property line

(self) -> int

property max_input

(self) -> int

property max_output

(self) -> int

property min_input

(self) -> int

property min_output

(self) -> int

property name

(self) -> str

property outputs

(self) -> list[onnx.onnx_cpp2py_export.defs.OpSchema.FormalParameter]

set_type_and_shape_inference_function
property since_version

(self) -> int

property support_level

(self) -> onnx.onnx_cpp2py_export.defs.OpSchema.SupportType

property type_constraints

(self) -> list[onnx.onnx_cpp2py_export.defs.OpSchema.TypeConstraintParam]

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'