openvino.inference_engine.IECore

class openvino.inference_engine.IECore

This class represents an Inference Engine entity and allows you to manipulate with plugins using unified interfaces.

__init__()

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__()

Initialize self.

add_extension(self, unicode extension_path, …)

Loads extension library to the plugin with a specified device name

get_config(self, unicode device_name, …)

Gets a configuration dedicated to device behavior.

get_metric(self, unicode device_name, …)

Gets a general runtime metric for dedicated hardware.

get_versions(self, unicode device_name)

Get a collections.namedtuple object with versions of the plugin specified

import_network(self, unicode model_file, …)

Creates an executable network from a previously exported network

load_network(self, network, str], …[, config])

Loads a network that was read from the Intermediate Representation (IR) to the plugin with specified device name and creates an ExecutableNetwork object of the IENetwork class.

query_network(self, IENetwork network, …)

Queries the plugin with specified device name what network layers are supported in the current configuration.

read_network(self, model, bytes, …)

Reads a network from Intermediate Representation (IR) or ONNX formats and creates an IENetwork.

register_plugin(self, unicode plugin_name, …)

Registers plugins specified in an .xml configuration file

register_plugins(self, unicode xml_config_file)

Registers plugins specified in an .xml configuration file

set_config(self, dict config, …)

Sets a configuration for a plugin

unregister_plugin(self, unicode device_name)

Unregisters a plugin with a specified device name

Attributes

available_devices

A list of devices.

add_extension(self, unicode extension_path: str, unicode device_name: str)

Loads extension library to the plugin with a specified device name

Parameters
  • extension_path – Path to the extensions library file to load to a plugin

  • device_name – A device name of a plugin to load the extensions to

Returns

None

Usage example:

ie = IECore()
ie.add_extension(extension_path="/some_dir/libcpu_extension_avx2.so", device_name="CPU")
available_devices

A list of devices. The devices are returned as [CPU, FPGA.0, FPGA.1, MYRIAD]. If there are more than one device of a specific type, they all are listed followed by a dot and a number.

get_config(self, unicode device_name: str, unicode config_name: str)

Gets a configuration dedicated to device behavior. The method targets to extract information which can be set via set_config method.

Note

When specifying a key value of a config, the “KEY_” prefix is omitted.

Parameters
  • device_name – A name of a device to get a config value.

  • config_name – A config name to request.

Returns

A config value corresponding to a config key.

Usage example:

ie = IECore()
ie.get_config(device_name="CPU", config_name="CPU_BIND_THREAD")
get_metric(self, unicode device_name: str, unicode metric_name: str)

Gets a general runtime metric for dedicated hardware. Enables to request common device properties, which are ExecutableNetwork agnostic, such as device name, temperature, and other devices-specific values.

Parameters
  • device_name – A name of a device to get a metric value.

  • metric_name – A metric name to request.

Returns

A metric value corresponding to a metric key.

Usage example:

ie = IECore()
ie.get_metric(metric_name="SUPPORTED_METRICS", device_name="CPU")
get_versions(self, unicode device_name: str)

Get a collections.namedtuple object with versions of the plugin specified

Parameters

device_name – Name of the the registered plugin

Returns

Dictionary mapping a plugin name and Versions collections.namedtuple object with the following fields:

  • major - major plugin integer version

  • minor - minor plugin integer version

  • build_number - plugin build number string

  • description - plugin description string

import_network(self, unicode model_file, unicode device_name, config=None, int num_requests=1)ExecutableNetwork

Creates an executable network from a previously exported network

Parameters
  • device_name – Name of device load executable network on

  • model_file – Full path to the location of the exported file

  • config – A dictionary of plugin configuration keys and their values

  • num_requests – A positive integer value of infer requests to be created. Number of infer requests is limited by device capabilities. Value 0 indicates that optimal number of infer requests will be created.

Returns

An ExecutableNetwork object

Usage example:

ie = IECore()
net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
exec_net = ie.load_network(network=net, device_name="MYRIAD", num_requests=2)
# export executable network
exec_net.export(path_to_file_to_save)
# import previously exported executable network
exec_net_imported = ie.import_network(model_file=path_to_file_to_save, device_name="MYRIAD")
load_network(self, network: [IENetwork, str], unicode device_name, config=None, int num_requests=1)ExecutableNetwork

Loads a network that was read from the Intermediate Representation (IR) to the plugin with specified device name and creates an ExecutableNetwork object of the IENetwork class. You can create as many networks as you need and use them simultaneously (up to the limitation of the hardware resources).

Parameters
  • network – A valid IENetwork instance. Model file name .xml, .onnx can also be passed as argument

  • device_name – A device name of a target plugin

  • config – A dictionary of plugin configuration keys and their values

  • num_requests – A positive integer value of infer requests to be created.

Number of infer requests is limited by device capabilities. Value 0 indicates that optimal number of infer requests will be created.

Returns

An ExecutableNetwork object

Usage example:

ie = IECore()
net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
exec_net = ie.load_network(network=net, device_name="CPU", num_requests=2)
query_network(self, IENetwork network, unicode device_name, config=None)

Queries the plugin with specified device name what network layers are supported in the current configuration. Please note that layers support depends on plugin configuration and loaded extensions.

Parameters
  • network – A valid IENetwork instance

  • device_name – A device name of a target plugin

  • config – A dictionary of plugin configuration keys and their values

Returns

A dictionary mapping layers and device names on which they are supported

Usage example:

ie = IECore()
net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
layers_map = ie.query_network(network=net, device_name="HETERO:GPU,CPU")
read_network(self, model: [str, bytes, os.PathLike], weights: [str, bytes, os.PathLike] = u'', bool init_from_buffer: bool = False)IENetwork

Reads a network from Intermediate Representation (IR) or ONNX formats and creates an IENetwork.

Parameters
  • model – A .xml, .onnx`or `.prototxt model file or string with IR.

  • weights – A .bin file of the IR. Depending on init_from_buffer value, can be a string path or bytes with file content.

  • init_from_buffer – Defines the way of how model and weights attributes are interpreted.

If False, attributes are interpreted as strings with paths to .xml and .bin files of IR. If True, they are interpreted as Python bytes object with .xml and .bin files content.

Returns

An IENetwork object

Usage example:

ie = IECore()
net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
register_plugin(self, unicode plugin_name: str, unicode device_name: str = u'')

Registers plugins specified in an .xml configuration file

Parameters
  • plugin_name – A name of a plugin. Depending on a platform, plugin_name is wrapped with a shared library suffix and a prefix to identify a full name of the library

  • device_name – A target device name for the plugin. If not specified, the method registers a plugin with the default name.

Returns

None

Usage example:

ie = IECore()
ie.register_plugin(plugin="MKLDNNPlugin", device_name="MY_NEW_PLUGIN")
register_plugins(self, unicode xml_config_file: str)

Registers plugins specified in an .xml configuration file

Parameters

xml_config_file – A full path to .xml file containing plugins configuration

Returns

None

Usage example:

ie = IECore()
ie.register_plugins("/localdisk/plugins/my_custom_cfg.xml")
set_config(self, dict config: dict, unicode device_name: str)

Sets a configuration for a plugin

Note

When specifying a key value of a config, the “KEY_” prefix is omitted.

Parameters
  • config – a dictionary of configuration parameters as keys and their values

  • device_name – a device name of a target plugin

Returns

None

Usage examples:

ie = IECore()
net = ie.read_network(model=path_to_xml_file, weights=path_to_bin_file)
ie.set_config(config={"DYN_BATCH_ENABLED": "YES"}, device_name="CPU")
unregister_plugin(self, unicode device_name: str)

Unregisters a plugin with a specified device name

Parameters

device_name – A device name of the plugin to unregister

Returns

None

Usage example:

ie = IECore()
ie.unregister_plugin(device_name="GPU")