openvino.runtime.Model

class openvino.runtime.Model

Bases: pybind11_builtins.pybind11_object

openvino.runtime.Model wraps ov::Model

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: openvino.pyopenvino.Model, results: List[openvino.pyopenvino.op.Result], sinks: List[openvino.pyopenvino.Node], parameters: List[openvino.pyopenvino.op.Parameter], name: str) -> None

    Create user-defined Model which is a representation of a model.

    param results

    List of results.

    type results

    List[op.Result]

    param sinks

    List of Nodes to be used as Sinks (e.g. Assign ops).

    type sinks

    List[openvino.runtime.Node]

    param parameters

    List of parameters.

    type parameters

    List[op.Parameter]

    param name

    String to set as model’s friendly name.

    type name

    str

  2. __init__(self: openvino.pyopenvino.Model, results: List[openvino.pyopenvino.Node], parameters: List[openvino.pyopenvino.op.Parameter], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model.

    param results

    List of Nodes to be used as results.

    type results

    List[openvino.runtime.Node]

    param parameters

    List of parameters.

    type parameters

    List[op.Parameter]

    param name

    String to set as model’s friendly name.

    type name

    str

  3. __init__(self: openvino.pyopenvino.Model, result: openvino.pyopenvino.Node, parameters: List[openvino.pyopenvino.op.Parameter], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model.

    param result

    Node to be used as result.

    type result

    openvino.runtime.Node

    param parameters

    List of parameters.

    type parameters

    List[op.Parameter]

    param name

    String to set as model’s friendly name.

    type name

    str

  4. __init__(self: openvino.pyopenvino.Model, results: List[ov::Output<ov::Node>], parameters: List[openvino.pyopenvino.op.Parameter], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model

    param results

    List of outputs.

    type results

    List[openvino.runtime.Output]

    param parameters

    List of parameters.

    type parameters

    List[op.Parameter]

    param name

    String to set as model’s friendly name.

    type name

    str

  5. __init__(self: openvino.pyopenvino.Model, results: List[ov::Output<ov::Node>], sinks: List[openvino.pyopenvino.Node], parameters: List[openvino.pyopenvino.op.Parameter], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model

    param results

    List of outputs.

    type results

    List[openvino.runtime.Output]

    param sinks

    List of Nodes to be used as Sinks (e.g. Assign ops).

    type sinks

    List[openvino.runtime.Node]

    param name

    String to set as model’s friendly name.

    type name

    str

  6. __init__(self: openvino.pyopenvino.Model, results: List[openvino.pyopenvino.op.Result], sinks: List[openvino.pyopenvino.Node], parameters: List[openvino.pyopenvino.op.Parameter], variables: List[openvino.pyopenvino.op.util.Variable], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model

    param results

    List of results.

    type results

    List[op.Result]

    param sinks

    List of Nodes to be used as Sinks (e.g. Assign ops).

    type sinks

    List[openvino.runtime.Node]

    param parameters

    List of parameters.

    type parameters

    List[op.Parameter]

    param variables

    List of variables.

    type variables

    List[op.util.Variable]

    param name

    String to set as model’s friendly name.

    type name

    str

  7. __init__(self: openvino.pyopenvino.Model, results: List[ov::Output<ov::Node>], sinks: List[openvino.pyopenvino.Node], parameters: List[openvino.pyopenvino.op.Parameter], variables: List[openvino.pyopenvino.op.util.Variable], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model

    param results

    List of results.

    type results

    List[openvino.runtime.Output]

    param sinks

    List of Nodes to be used as Sinks (e.g. Assign ops).

    type sinks

    List[openvino.runtime.Node]

    param variables

    List of variables.

    type variables

    List[op.util.Variable]

    param name

    String to set as model’s friendly name.

    type name

    str

  8. __init__(self: openvino.pyopenvino.Model, results: List[openvino.pyopenvino.op.Result], parameters: List[openvino.pyopenvino.op.Parameter], variables: List[openvino.pyopenvino.op.util.Variable], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model

    param results

    List of results.

    type results

    List[op.Result]

    param parameters

    List of parameters.

    type parameters

    List[op.Parameter]

    param variables

    List of variables.

    type variables

    List[op.util.Variable]

    param name

    String to set as model’s friendly name.

    type name

    str

  9. __init__(self: openvino.pyopenvino.Model, results: List[ov::Output<ov::Node>], parameters: List[openvino.pyopenvino.op.Parameter], variables: List[openvino.pyopenvino.op.util.Variable], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model

    param results

    List of results.

    type results

    List[openvino.runtime.Output]

    param parameters

    List of parameters.

    type parameters

    List[op.Parameter]

    param name

    String to set as model’s friendly name.

    type name

    str

Methods

__delattr__(name, /)

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__(value, /)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__(*args, **kwargs)

Overloaded function.

__init_subclass__

This method is called when a class is subclassed.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__ne__(value, /)

Return self!=value.

__new__(**kwargs)

Create and return a new object.

__reduce__()

Helper for pickle.

__reduce_ex__(protocol, /)

Helper for pickle.

__repr__(self)

__setattr__(name, value, /)

Implement setattr(self, name, value).

__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__

Abstract classes can override this to customize issubclass().

add_outputs(self, outputs)

clone(self)

Return a copy of self.

evaluate(self, output_tensors, …)

Evaluate the model on inputs, putting results in outputs

get_friendly_name(self)

Gets the friendly name for a model.

get_name(self)

Get the unique name of the model.

get_ops(self)

Return ops used in the model.

get_ordered_ops(self)

Return ops used in the model in topological order.

get_output_element_type(self, index)

Return the element type of output i

get_output_op(self, index)

Return the op that generates output i

get_output_partial_shape(self, index)

Return the partial shape of element i

get_output_shape(self, index)

Return the shape of element i

get_output_size(self)

Return the number of outputs for the model.

get_parameter_index(self, parameter)

Return the index position of parameter

get_parameters(self)

Return the model parameters.

get_result(self)

Return single result.

get_result_index(*args, **kwargs)

Overloaded function.

get_results(self)

Return a list of model outputs.

input(*args, **kwargs)

Overloaded function.

is_dynamic(self)

Returns true if any of the op’s defined in the model contains partial shape.

output(*args, **kwargs)

Overloaded function.

replace_parameter(self, parameter_index, …)

Replace the parameter_index parameter of the model with parameter

reshape(*args, **kwargs)

Overloaded function.

set_friendly_name(self, name)

Sets a friendly name for a model.

validate_nodes_and_infer_types(self)

Attributes

__pybind11_module_local_v4_gcc_libstdcpp_cxxabi1011__

friendly_name

inputs

name

outputs

__class__

alias of pybind11_builtins.pybind11_type

__delattr__(name, /)

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__(value, /)

Return self==value.

__format__(format_spec, /)

Default object formatter.

__ge__(value, /)

Return self>=value.

__getattribute__(name, /)

Return getattr(self, name).

__gt__(value, /)

Return self>value.

__hash__()

Return hash(self).

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: openvino.pyopenvino.Model, results: List[openvino.pyopenvino.op.Result], sinks: List[openvino.pyopenvino.Node], parameters: List[openvino.pyopenvino.op.Parameter], name: str) -> None

    Create user-defined Model which is a representation of a model.

    param results

    List of results.

    type results

    List[op.Result]

    param sinks

    List of Nodes to be used as Sinks (e.g. Assign ops).

    type sinks

    List[openvino.runtime.Node]

    param parameters

    List of parameters.

    type parameters

    List[op.Parameter]

    param name

    String to set as model’s friendly name.

    type name

    str

  2. __init__(self: openvino.pyopenvino.Model, results: List[openvino.pyopenvino.Node], parameters: List[openvino.pyopenvino.op.Parameter], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model.

    param results

    List of Nodes to be used as results.

    type results

    List[openvino.runtime.Node]

    param parameters

    List of parameters.

    type parameters

    List[op.Parameter]

    param name

    String to set as model’s friendly name.

    type name

    str

  3. __init__(self: openvino.pyopenvino.Model, result: openvino.pyopenvino.Node, parameters: List[openvino.pyopenvino.op.Parameter], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model.

    param result

    Node to be used as result.

    type result

    openvino.runtime.Node

    param parameters

    List of parameters.

    type parameters

    List[op.Parameter]

    param name

    String to set as model’s friendly name.

    type name

    str

  4. __init__(self: openvino.pyopenvino.Model, results: List[ov::Output<ov::Node>], parameters: List[openvino.pyopenvino.op.Parameter], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model

    param results

    List of outputs.

    type results

    List[openvino.runtime.Output]

    param parameters

    List of parameters.

    type parameters

    List[op.Parameter]

    param name

    String to set as model’s friendly name.

    type name

    str

  5. __init__(self: openvino.pyopenvino.Model, results: List[ov::Output<ov::Node>], sinks: List[openvino.pyopenvino.Node], parameters: List[openvino.pyopenvino.op.Parameter], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model

    param results

    List of outputs.

    type results

    List[openvino.runtime.Output]

    param sinks

    List of Nodes to be used as Sinks (e.g. Assign ops).

    type sinks

    List[openvino.runtime.Node]

    param name

    String to set as model’s friendly name.

    type name

    str

  6. __init__(self: openvino.pyopenvino.Model, results: List[openvino.pyopenvino.op.Result], sinks: List[openvino.pyopenvino.Node], parameters: List[openvino.pyopenvino.op.Parameter], variables: List[openvino.pyopenvino.op.util.Variable], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model

    param results

    List of results.

    type results

    List[op.Result]

    param sinks

    List of Nodes to be used as Sinks (e.g. Assign ops).

    type sinks

    List[openvino.runtime.Node]

    param parameters

    List of parameters.

    type parameters

    List[op.Parameter]

    param variables

    List of variables.

    type variables

    List[op.util.Variable]

    param name

    String to set as model’s friendly name.

    type name

    str

  7. __init__(self: openvino.pyopenvino.Model, results: List[ov::Output<ov::Node>], sinks: List[openvino.pyopenvino.Node], parameters: List[openvino.pyopenvino.op.Parameter], variables: List[openvino.pyopenvino.op.util.Variable], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model

    param results

    List of results.

    type results

    List[openvino.runtime.Output]

    param sinks

    List of Nodes to be used as Sinks (e.g. Assign ops).

    type sinks

    List[openvino.runtime.Node]

    param variables

    List of variables.

    type variables

    List[op.util.Variable]

    param name

    String to set as model’s friendly name.

    type name

    str

  8. __init__(self: openvino.pyopenvino.Model, results: List[openvino.pyopenvino.op.Result], parameters: List[openvino.pyopenvino.op.Parameter], variables: List[openvino.pyopenvino.op.util.Variable], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model

    param results

    List of results.

    type results

    List[op.Result]

    param parameters

    List of parameters.

    type parameters

    List[op.Parameter]

    param variables

    List of variables.

    type variables

    List[op.util.Variable]

    param name

    String to set as model’s friendly name.

    type name

    str

  9. __init__(self: openvino.pyopenvino.Model, results: List[ov::Output<ov::Node>], parameters: List[openvino.pyopenvino.op.Parameter], variables: List[openvino.pyopenvino.op.util.Variable], name: str = ‘’) -> None

    Create user-defined Model which is a representation of a model

    param results

    List of results.

    type results

    List[openvino.runtime.Output]

    param parameters

    List of parameters.

    type parameters

    List[op.Parameter]

    param name

    String to set as model’s friendly name.

    type name

    str

__init_subclass__()

This method is called when a class is subclassed.

The default implementation does nothing. It may be overridden to extend subclasses.

__le__(value, /)

Return self<=value.

__lt__(value, /)

Return self<value.

__ne__(value, /)

Return self!=value.

__new__(**kwargs)

Create and return a new object. See help(type) for accurate signature.

__pybind11_module_local_v4_gcc_libstdcpp_cxxabi1011__ = <capsule object NULL>
__reduce__()

Helper for pickle.

__reduce_ex__(protocol, /)

Helper for pickle.

__repr__(self: openvino.pyopenvino.Model) → str
__setattr__(name, value, /)

Implement setattr(self, name, value).

__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

add_outputs(self: openvino.pyopenvino.Model, outputs: handle) → List[ov::Output<ov::Node>]
clone(self: openvino.pyopenvino.Model) → openvino.pyopenvino.Model

Return a copy of self. :return: A copy of self. :rtype: openvino.runtime.Model

evaluate(self: openvino.pyopenvino.Model, output_tensors: List[ov::Tensor], input_tensors: List[ov::Tensor], evaluation_context: openvino.pyopenvino.RTMap = <openvino.pyopenvino.RTMap object at 0x7f79b8bc1530>) → bool

Evaluate the model on inputs, putting results in outputs

Parameters
  • output_tensors (List[openvino.runtime.Tensor]) – Tensors for the outputs to compute. One for each result

  • input_tensors (List[openvino.runtime.Tensor]) – Tensors for the inputs. One for each inputs.

  • evaluation_context (openvino.runtime.RTMap) – Storage of additional settings and attributes that can be used when evaluating the model. This additional information can be shared across nodes.

Return type

bool

property friendly_name
get_friendly_name(self: openvino.pyopenvino.Model) → str

Gets the friendly name for a model. If no friendly name has been set via set_friendly_name then the model’s unique name is returned.

Returns

String with a friendly name of the model.

Return type

str

get_name(self: openvino.pyopenvino.Model) → str

Get the unique name of the model.

Returns

String with a name of the model.

Return type

str

get_ops(self: openvino.pyopenvino.Model) → List[openvino.pyopenvino.Node]

Return ops used in the model.

Returns

List of Nodes representing ops used in model.

Return type

List[openvino.runtime.Node]

get_ordered_ops(self: openvino.pyopenvino.Model) → List[openvino.pyopenvino.Node]

Return ops used in the model in topological order.

Returns

List of sorted Nodes representing ops used in model.

Return type

List[openvino.runtime.Node]

get_output_element_type(self: openvino.pyopenvino.Model, index: int) → openvino.pyopenvino.Type

Return the element type of output i

Parameters

index (int) – output index

Returns

Type object of output i

Return type

openvino.runtime.Type

get_output_op(self: openvino.pyopenvino.Model, index: int) → openvino.pyopenvino.Node

Return the op that generates output i

Parameters

index (output index) – output index

Returns

Node object that generates output i

Return type

openvino.runtime.Node

get_output_partial_shape(self: openvino.pyopenvino.Model, index: int) → openvino.pyopenvino.PartialShape

Return the partial shape of element i

Parameters

index (int) – element index

Returns

PartialShape object of element i

Return type

openvino.runtime.PartialShape

get_output_shape(self: openvino.pyopenvino.Model, index: int) → openvino.pyopenvino.Shape

Return the shape of element i

Parameters

index (int) – element index

Returns

Shape object of element i

Return type

openvino.runtime.Shape

get_output_size(self: openvino.pyopenvino.Model) → int

Return the number of outputs for the model.

Returns

Number of outputs.

Return type

int

get_parameter_index(self: openvino.pyopenvino.Model, parameter: openvino.pyopenvino.op.Parameter) → int

Return the index position of parameter

Return -1 if parameter not matched.

Parameters

parameter (op.Parameter) – Parameter, which index is to be found.

Returns

Index for parameter

Return type

int

get_parameters(self: openvino.pyopenvino.Model) → List[openvino.pyopenvino.op.Parameter]

Return the model parameters.

Returns

ParameterVector containing model parameters.

Return type

ParameterVector

get_result(self: openvino.pyopenvino.Model) → openvino.pyopenvino.Node

Return single result.

Returns

Node object representing result.

Return type

openvino.runtime.Node

get_result_index(*args, **kwargs)

Overloaded function.

  1. get_result_index(self: openvino.pyopenvino.Model, value: ov::Output<ov::Node>) -> int

    Return index of result.

    Return -1 if value not matched.

    param value

    Output containing Node

    type value

    openvino.runtime.Output

    return

    Index for value referencing it.

    rtype

    int

  2. get_result_index(self: openvino.pyopenvino.Model, value: ov::Output<ov::Node const>) -> int

    Return index of result.

    Return -1 if value not matched.

    param value

    Output containing Node

    type value

    openvino.runtime.Output

    return

    Index for value referencing it.

    rtype

    int

get_results(self: openvino.pyopenvino.Model) → List[openvino.pyopenvino.op.Result]

Return a list of model outputs.

Returns

ResultVector containing model parameters.

Return type

ResultVector

input(*args, **kwargs)

Overloaded function.

  1. input(self: openvino.pyopenvino.Model) -> ov::Output<ov::Node>

  2. input(self: openvino.pyopenvino.Model, index: int) -> ov::Output<ov::Node>

  3. input(self: openvino.pyopenvino.Model, tensor_name: str) -> ov::Output<ov::Node>

  4. input(self: openvino.pyopenvino.Model) -> ov::Output<ov::Node const>

  5. input(self: openvino.pyopenvino.Model, index: int) -> ov::Output<ov::Node const>

  6. input(self: openvino.pyopenvino.Model, tensor_name: str) -> ov::Output<ov::Node const>

property inputs
is_dynamic(self: openvino.pyopenvino.Model) → bool

Returns true if any of the op’s defined in the model contains partial shape.

Return type

bool

property name
output(*args, **kwargs)

Overloaded function.

  1. output(self: openvino.pyopenvino.Model) -> ov::Output<ov::Node>

  2. output(self: openvino.pyopenvino.Model, index: int) -> ov::Output<ov::Node>

  3. output(self: openvino.pyopenvino.Model, tensor_name: str) -> ov::Output<ov::Node>

  4. output(self: openvino.pyopenvino.Model) -> ov::Output<ov::Node const>

  5. output(self: openvino.pyopenvino.Model, index: int) -> ov::Output<ov::Node const>

  6. output(self: openvino.pyopenvino.Model, tensor_name: str) -> ov::Output<ov::Node const>

property outputs
replace_parameter(self: openvino.pyopenvino.Model, parameter_index: int, parameter: openvino.pyopenvino.op.Parameter) → None

Replace the parameter_index parameter of the model with parameter

All users of the parameter_index parameter are redirected to parameter , and the parameter_index entry in the model parameter list is replaced with parameter

Parameters
  • parameter_index (int) – The index of the parameter to replace.

  • parameter (op.Parameter) – The parameter to substitute for the parameter_index parameter.

reshape(*args, **kwargs)

Overloaded function.

  1. reshape(self: openvino.pyopenvino.Model, partial_shape: openvino.pyopenvino.PartialShape) -> None

    Reshape model input.

    GIL is released while running this function.

    param partial_shape

    New shape.

    type partial_shape

    openvino.runtime.PartialShape

    :return : void

  2. reshape(self: openvino.pyopenvino.Model, partial_shape: list) -> None

    Reshape model input.

    GIL is released while running this function.

    param partial_shape

    New shape.

    type partial_shape

    list

    :return : void

  3. reshape(self: openvino.pyopenvino.Model, partial_shape: tuple) -> None

    Reshape model input.

    GIL is released while running this function.

    param partial_shape

    New shape.

    type partial_shape

    tuple

    :return : void

  4. reshape(self: openvino.pyopenvino.Model, partial_shape: str) -> None

    Reshape model input.

    GIL is released while running this function.

    param partial_shape

    New shape.

    type partial_shape

    str

    :return : void

  5. reshape(self: openvino.pyopenvino.Model, partial_shapes: dict) -> None

Reshape model inputs.

The allowed types of keys in the partial_shapes dictionary are:

  1. int, input index

  2. str, input tensor name

  3. openvino.runtime.Output

The allowed types of values in the partial_shapes are:

  1. openvino.runtime.PartialShape

  2. list consisting of dimensions

  3. tuple consisting of dimensions

  4. str, string representation of openvino.runtime.PartialShape

When list or tuple are used to describe dimensions, each dimension can be written in form:

  1. non-negative int which means static value for the dimension

  2. [min, max], dynamic dimension where min specifies lower bound and max specifies upper bound; the range includes both min and max; using -1 for min or max means no known bound

  3. (min, max), the same as above

(4) -1 is a dynamic dimension without known bounds (4) openvino.runtime.Dimension (5) str using next syntax:

‘?’ - to define fully dynamic dimension ‘1’ - to define dimension which length is 1 ‘1..10’ - to define bounded dimension ‘..10’ or ‘1..’ to define dimension with only lower or only upper limit

Reshape model input.

GIL is released while running this function.

param partial_shapes

New shapes.

type partial_shapes

Dict[keys, values]

set_friendly_name(self: openvino.pyopenvino.Model, name: str) → None

Sets a friendly name for a model. This does not overwrite the unique name of the model and is retrieved via get_friendly_name(). Used mainly for debugging.

Parameters

name (str) – String to set as the friendly name.

validate_nodes_and_infer_types(self: openvino.pyopenvino.Model) → None