onnx.checker

CheckerContext

onnx.checker.DEFAULT_CONTEXT

alias of <onnx.onnx_cpp2py_export.checker.CheckerContext object>

The onnx.checker module

Graph utilities for checking whether an ONNX proto message is legal.

exception onnx.checker.ValidationError

Bases: Exception

onnx.checker.check_attribute(attr: ~onnx.onnx_ml_pb2.AttributeProto, ctx: ~onnx.onnx_cpp2py_export.checker.CheckerContext = <onnx.onnx_cpp2py_export.checker.CheckerContext object>, lexical_scope_ctx: ~onnx.onnx_cpp2py_export.checker.LexicalScopeContext = <onnx.onnx_cpp2py_export.checker.LexicalScopeContext object>) None[source]
onnx.checker.check_function(function: ~onnx.onnx_ml_pb2.FunctionProto, ctx: ~onnx.onnx_cpp2py_export.checker.CheckerContext | None = None, lexical_scope_ctx: ~onnx.onnx_cpp2py_export.checker.LexicalScopeContext = <onnx.onnx_cpp2py_export.checker.LexicalScopeContext object>) None[source]
onnx.checker.check_graph(graph: ~onnx.onnx_ml_pb2.GraphProto, ctx: ~onnx.onnx_cpp2py_export.checker.CheckerContext = <onnx.onnx_cpp2py_export.checker.CheckerContext object>, lexical_scope_ctx: ~onnx.onnx_cpp2py_export.checker.LexicalScopeContext = <onnx.onnx_cpp2py_export.checker.LexicalScopeContext object>) None[source]
onnx.checker.check_model(model: ModelProto | str | bytes | PathLike, full_check: bool = False, skip_opset_compatibility_check: bool = False, check_custom_domain: bool = False) None[source]

Check the consistency of a model.

An exception will be raised if the model’s ir_version is not set properly or is higher than checker’s ir_version, or if the model has duplicate keys in metadata_props.

If IR version >= 3, the model must specify opset_import. If IR version < 3, the model cannot have any opset_import specified.

Parameters:
  • model – Model to check. If model is a path, the function checks model path first. If the model bytes size is larger than 2GB, function should be called using model path.

  • full_check – If True, the function also runs shape inference check.

  • skip_opset_compatibility_check – If True, the function skips the check for opset compatibility.

  • check_custom_domain – If True, the function will check all domains. Otherwise only check built-in domains.

onnx.checker.check_node(node: ~onnx.onnx_ml_pb2.NodeProto, ctx: ~onnx.onnx_cpp2py_export.checker.CheckerContext = <onnx.onnx_cpp2py_export.checker.CheckerContext object>, lexical_scope_ctx: ~onnx.onnx_cpp2py_export.checker.LexicalScopeContext = <onnx.onnx_cpp2py_export.checker.LexicalScopeContext object>) None[source]
onnx.checker.check_sparse_tensor(sparse: ~onnx.onnx_ml_pb2.SparseTensorProto, ctx: ~onnx.onnx_cpp2py_export.checker.CheckerContext = <onnx.onnx_cpp2py_export.checker.CheckerContext object>) None[source]
onnx.checker.check_tensor(tensor: ~onnx.onnx_ml_pb2.TensorProto, ctx: ~onnx.onnx_cpp2py_export.checker.CheckerContext = <onnx.onnx_cpp2py_export.checker.CheckerContext object>) None[source]
onnx.checker.check_value_info(value_info: ~onnx.onnx_ml_pb2.ValueInfoProto, ctx: ~onnx.onnx_cpp2py_export.checker.CheckerContext = <onnx.onnx_cpp2py_export.checker.CheckerContext object>) None[source]