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)

__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.

get_rt_info(*args, **kwargs)

Overloaded function.

has_rt_info(*args, **kwargs)

Overloaded function.

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.

set_rt_info(*args, **kwargs)

Overloaded function.

validate_nodes_and_infer_types(self)

Attributes

__pybind11_module_local_v4_gcc_libstdcpp_cxxabi1014__

friendly_name

inputs

name

outputs

rt_info

__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)
__pybind11_module_local_v4_gcc_libstdcpp_cxxabi1014__ = <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 0x7f6eee87ab30>) 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

get_rt_info(*args, **kwargs)

Overloaded function.

  1. get_rt_info(self: openvino._pyopenvino.Model) -> openvino._pyopenvino.RTMap

    Returns PyRTMap which is a dictionary of user defined runtime info.

    return

    A dictionary of user defined data.

    rtype

    openvino.runtime.RTMap

  2. get_rt_info(self: openvino._pyopenvino.Model, path: list) -> object

    Returns runtime attribute.

    param path

    List of strings which defines a path to runtime info.

    type path

    List[str]

    return

    A runtime attribute.

    rtype

    Any

  3. get_rt_info(self: openvino._pyopenvino.Model, path: str) -> object

    Returns runtime attribute.

    param path

    List of strings which defines a path to runtime info.

    type path

    str

    return

    A runtime attribute.

    rtype

    Any

has_rt_info(*args, **kwargs)

Overloaded function.

  1. has_rt_info(self: openvino._pyopenvino.Model, path: list) -> bool

    Checks if given path exists in runtime info of the model.

    param path

    List of strings which defines a path to runtime info.

    type path

    List[str]

    return

    True if path exists, otherwise False.

    rtype

    bool

  2. has_rt_info(self: openvino._pyopenvino.Model, path: str) -> bool

    Checks if given path exists in runtime info of the model.

    param path

    List of strings which defines a path to runtime info.

    type path

    str

    return

    True if path exists, otherwise False.

    rtype

    bool

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]

property rt_info
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.

set_rt_info(*args, **kwargs)

Overloaded function.

  1. set_rt_info(self: openvino._pyopenvino.Model, obj: object, path: list) -> None

    Add value inside runtime info

    param obj

    value for the runtime info

    type obj

    py:object

    param path

    List of strings which defines a path to runtime info.

    type path

    List[str]

  2. set_rt_info(self: openvino._pyopenvino.Model, obj: object, path: str) -> None

    Add value inside runtime info

    param obj

    value for the runtime info

    type obj

    Any

    param path

    String which defines a path to runtime info.

    type path

    str

validate_nodes_and_infer_types(self: openvino._pyopenvino.Model) None