openvino.inference_engine.IECore¶
- class openvino.inference_engine.IECore¶
Bases:
object
This class represents an Inference Engine entity and allows you to manipulate with plugins using unified interfaces.
- __init__()¶
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__
()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)IECore.__reduce_cython__(self)
__reduce_ex__
(protocol, /)Helper for pickle.
__repr__
()Return repr(self).
__setattr__
(name, value, /)Implement setattr(self, name, value).
IECore.__setstate_cython__(self, __pyx_state)
Size of object in memory, in bytes.
__str__
()Return str(self).
Abstract classes can override this to customize issubclass().
add_extension
(self, str extension_path, ...)Loads extension library to the plugin with a specified device name
get_config
(self, str device_name, ...)Gets a configuration dedicated to device behavior.
get_metric
(self, str device_name, ...)Gets a general runtime metric for dedicated hardware.
get_versions
(self, str device_name)Get a
collections.namedtuple
object with versions of the plugin specifiedimport_network
(self, str model_file, ...[, ...])Creates an executable network from a previously exported network
load_network
(self, network, str][, ...])Loads a network that was read from the Intermediate Representation (IR) to the plugin with specified device name and creates an
ExecutableNetwork
object of theIENetwork
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, str plugin_name, ...)Registers plugins specified in an .xml configuration file
register_plugins
(self, str xml_config_file)Registers plugins specified in an .xml configuration file
set_config
(self, dict config, str device_name)Sets a configuration for a plugin
unregister_plugin
(self, str device_name)Unregisters a plugin with a specified device name
Attributes
A list of devices.
- __class__¶
alias of
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__()¶
- __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)¶
- __pyx_vtable__ = <capsule object NULL>¶
- __reduce__()¶
IECore.__reduce_cython__(self)
- __reduce_ex__(protocol, /)¶
Helper for pickle.
- __repr__()¶
Return repr(self).
- __setattr__(name, value, /)¶
Implement setattr(self, name, value).
- __setstate__()¶
IECore.__setstate_cython__(self, __pyx_state)
- __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_extension(self, str extension_path: str, str 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, str device_name: str, str 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, str device_name: str, str 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, str 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, str model_file, str 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], device_name=None, 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 theIENetwork
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 argumentdevice_name – A device name of a target plugin, if no device_name is set then it will use AUTO device as default.
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, str 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
instancedevice_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] = '', 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, str plugin_name: str, str device_name: str = '')¶
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="openvino_intel_cpu_plugin", device_name="MY_NEW_PLUGIN")
- register_plugins(self, str 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, str 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, str 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")