onnx.defs

Opset 版本

onnx.defs.onnx_opset_version() int[源代码]

返回域 ai.onnx 的当前 opset 版本。

算子和函数模式

onnx.defs.has()

has_schema(*args, **kwargs) 重载函数。

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

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

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

重载函数。

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

返回算子 op_type 在特定版本下的模式。

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

返回算子 op_type 在特定版本下的模式。

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

返回所有现有算子在最新版本下的模式。

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

返回所有现有算子及其所有版本的模式。

onnx.defs.get_function_ops() list[OpSchema][源代码]

返回定义为函数的算子。

onnx.defs.register_schema(schema: OpSchema) None[源代码]

注册一个用户提供的 OpSchema。

如有必要,此函数会为提供的域扩展可用的算子集版本。

参数:

schema – 要注册的 OpSchema。

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

注销指定的 OpSchema。

class OpSchema

class onnx.defs.OpSchema

算子的模式。

class AttrType

成员

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

成员

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

成员

Single

Optional

Variadic

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

成员

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: collections.abc.Sequence[bytes]) bytes
get_context_dependent_function_with_opset_version(self: onnx.onnx_cpp2py_export.defs.OpSchema, arg0: SupportsInt, arg1: bytes, arg2: collections.abc.Sequence[bytes]) bytes
get_function_with_opset_version(self: onnx.onnx_cpp2py_export.defs.OpSchema, arg0: SupportsInt) bytes
get_type_and_shape_inference_function(self: onnx.onnx_cpp2py_export.defs.OpSchema) collections.abc.Callable[[onnx::InferenceContext], None]
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: SupportsInt) bool
property line
property max_input
property max_output
property min_input
property min_output
property name
property outputs
set_type_and_shape_inference_function(self: onnx.onnx_cpp2py_export.defs.OpSchema, arg0: collections.abc.Callable[[onnx::InferenceContext], None]) onnx.onnx_cpp2py_export.defs.OpSchema
property since_version
property support_level
property type_constraints

异常

class onnx.defs.SchemaError

常量

onnx 包中官方支持的域。

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'