module onnx_tools._onnx_check_model#

Inheritance diagram of mlprodict.onnx_tools._onnx_check_model

Short summary#

module mlprodict.onnx_tools._onnx_check_model

Python implementation of onnx.checker.check_model.

source on GitHub

Classes#

class

truncated documentation

CheckerContext

Class hosting information about a graph.

CheckerContextDefaultRegistry

Registry.

LexicalScopeContext

Construct an instance with the lexical scope from the parent graph to allow lookup of names from that scope via this_or_ancestor_graph_has. …

OnnxCheckError

Raised when a model fails check.

Schema

Wrapper around a schema.

UndefinedSchema

Undefined schema.

Functions#

function

truncated documentation

_check_data_field

_check_field

_check_function

_check_graph

_check_map

_check_model

_check_model_local_functions

_check_node

_check_opset_compatibility

_check_optional

_check_sequence

_check_sparse_tensor

_check_sparse_tensor_indices_1

Check that the index data stored in a SparseTensorProto is valid. indices: a 1-dimensional tensor; indices[i] represents …

_check_sparse_tensor_indices_2

Check that the index data stored in a SparseTensorProto is valid. indices: a 2-dimensional tensor; indices[i,j] represents …

_check_tensor

_check_value_info

_enforce_has_field

_enforce_has_repeated_field

_enforce_non_empty_field

_get_version_for_domain

_parse_data

check_attribute

NB: This is a generic “attribute well-formedness” check, it doesn’t actually test if an attribute is valid per a schema. …

check_is_experimental_op

Tells if an operator is experimentation.

check_model

Checks a model is consistent with ONNX language. The function fails if the model is not consistent.

Properties#

property

truncated documentation

deprecated_

Returns False.

Methods#

method

truncated documentation

__getattr__

__init__

__init__

__init__

__init__

__init__

add

Adds a name to the context.

copy

Copies the instance.

get_ir_version

Accessor.

get_model_dir

Accessor.

get_opset_imports

Accessor.

get_schema

Accessor.

get_schema_registry

Accessor.

GetSchema

Accessor.

is_main_graph

Accessor.

num_inputs_allowed

Not implemented yet.

num_outputs_allowed

Not implemented yet.

set_ir_version

Accessor.

set_is_main_graph

Accessor.

set_model_dir

Accessor.

set_opset_imports

Accessor.

set_schema_registry

Accessor.

this_graph_has

Checks the context includes a specific name.

this_or_ancestor_graph_has

Checks the context and its ancestor includes a specific name.

verify

Verifies a node is consistent with ONNX language.

verify

Verifies a, undefined node is consistent with ONNX language.

Documentation#

Python implementation of onnx.checker.check_model.

source on GitHub

class mlprodict.onnx_tools._onnx_check_model.CheckerContext(ctx=None)#

Bases: object

Class hosting information about a graph.

source on GitHub

__init__(ctx=None)#
get_ir_version()#

Accessor.

get_model_dir()#

Accessor.

get_opset_imports()#

Accessor.

get_schema_registry()#

Accessor.

is_main_graph()#

Accessor.

set_ir_version(v)#

Accessor.

set_is_main_graph(is_main_graph)#

Accessor.

set_model_dir(model_dir)#

Accessor.

set_opset_imports(imps)#

Accessor.

set_schema_registry(schema_registry)#

Accessor.

class mlprodict.onnx_tools._onnx_check_model.CheckerContextDefaultRegistry#

Bases: object

Registry.

source on GitHub

GetSchema(op_type, version, domain)#

Accessor.

get_schema(op_type, version, domain)#

Accessor.

class mlprodict.onnx_tools._onnx_check_model.LexicalScopeContext(parent_context=None)#

Bases: object

Construct an instance with the lexical scope from the parent graph to allow lookup of names from that scope via this_or_ancestor_graph_has. The caller must ensure parent_context remains valid for the entire lifetime of the new instance. Alternatively, if that cannot be guaranteed, create an instance with the default constructor and populate output_names with the values from the parent scope so the values are copied instead.

source on GitHub

__init__(parent_context=None)#
add(name)#

Adds a name to the context.

copy()#

Copies the instance.

this_graph_has(name)#

Checks the context includes a specific name.

this_or_ancestor_graph_has(name)#

Checks the context and its ancestor includes a specific name.

exception mlprodict.onnx_tools._onnx_check_model.OnnxCheckError(msg, proto)#

Bases: RuntimeError

Raised when a model fails check.

Parameters:
  • msg – message

  • proto – proto

source on GitHub

__init__(msg, proto)#
class mlprodict.onnx_tools._onnx_check_model.Schema(schema)#

Bases: object

Wrapper around a schema.

source on GitHub

__getattr__(attr)#
__init__(schema)#
num_inputs_allowed(n)#

Not implemented yet.

num_outputs_allowed(n)#

Not implemented yet.

verify(node)#

Verifies a node is consistent with ONNX language.

class mlprodict.onnx_tools._onnx_check_model.UndefinedSchema(name, version, domain)#

Bases: object

Undefined schema.

source on GitHub

__init__(name, version, domain)#
property deprecated_#

Returns False.

verify(node)#

Verifies a, undefined node is consistent with ONNX language.

mlprodict.onnx_tools._onnx_check_model._check_data_field(tensor, field, num_value_fields)#
mlprodict.onnx_tools._onnx_check_model._check_field(tensor, field, value_field, nelem)#
mlprodict.onnx_tools._onnx_check_model._check_function(function, ctx, parent_lex)#
mlprodict.onnx_tools._onnx_check_model._check_graph(graph, ctx, parent_lex)#
mlprodict.onnx_tools._onnx_check_model._check_map(map, ctx)#
mlprodict.onnx_tools._onnx_check_model._check_model(model, ctx)#
mlprodict.onnx_tools._onnx_check_model._check_model_local_functions(model, ctx, parent_lex)#
mlprodict.onnx_tools._onnx_check_model._check_node(node, ctx, lex_ctx)#
mlprodict.onnx_tools._onnx_check_model._check_opset_compatibility(node, ctx, func_opset_imports, model_opset_imports)#
mlprodict.onnx_tools._onnx_check_model._check_optional(optional, ctx)#
mlprodict.onnx_tools._onnx_check_model._check_sequence(sequence, ctx)#
mlprodict.onnx_tools._onnx_check_model._check_sparse_tensor(sparse_tensor_proto, ctx)#
mlprodict.onnx_tools._onnx_check_model._check_sparse_tensor_indices_1(indices, sparse_tensor_proto, nnz)#

Check that the index data stored in a SparseTensorProto is valid. indices: a 1-dimensional tensor; indices[i] represents the linearized index value for the i-th nonzero value.

source on GitHub

mlprodict.onnx_tools._onnx_check_model._check_sparse_tensor_indices_2(indices, sparse_tensor_proto, nnz)#

Check that the index data stored in a SparseTensorProto is valid. indices: a 2-dimensional tensor; indices[i,j] represents the j-th index value for the i-th nonzero value.

source on GitHub

mlprodict.onnx_tools._onnx_check_model._check_tensor(tensor, ctx)#
mlprodict.onnx_tools._onnx_check_model._check_value_info(value_info, ctx)#
mlprodict.onnx_tools._onnx_check_model._enforce_has_field(proto, field)#
mlprodict.onnx_tools._onnx_check_model._enforce_has_repeated_field(proto, field)#
mlprodict.onnx_tools._onnx_check_model._enforce_non_empty_field(proto, field)#
mlprodict.onnx_tools._onnx_check_model._get_version_for_domain(domain, opset_imports)#
mlprodict.onnx_tools._onnx_check_model._parse_data(dtype, indices)#
mlprodict.onnx_tools._onnx_check_model.check_attribute(attr, ctx, lex_ctx)#

NB: This is a generic “attribute well-formedness” check, it doesn’t actually test if an attribute is valid per a schema.

source on GitHub

mlprodict.onnx_tools._onnx_check_model.check_is_experimental_op(node_op_type)#

Tells if an operator is experimentation.

mlprodict.onnx_tools._onnx_check_model.check_model(model)#

Checks a model is consistent with ONNX language. The function fails if the model is not consistent.

Parameters:

modelModelProto

source on GitHub