Public Member Functions
ie_api.IECore Class Reference

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

Public Member Functions

def __init__ (self, xml_config_file="")
 Class constructor. More...

 
def get_versions (self, device_name)
 Get a namedtuple object with versions of the plugin specified. More...

 
def read_network
 Reads a network from the Intermediate Representation (IR) and creates an IENetwork. More...

 
def load_network (self, IENetwork, network, str, device_name, config=None, int, num_requests=1)
 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. More...

 
def import_network (self, str, model_file, str, device_name, config=None, int, num_requests=1)
 Creates an executable network from a previously exported network. More...

 
def 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. More...

 
def set_config (self, config, device_name)
 Sets a configuration for a plugin. More...

 
def register_plugin (self, plugin_name, device_name)
 Registers plugins specified in an .xml configuration file. More...

 
def register_plugins (self, xml_config_file)
 Registers plugins specified in an .xml configuration file. More...

 
def unregister_plugin (self, device_name)
 Unregisters a plugin with a specified device name. More...

 
def add_extension
 Loads extension library to the plugin with a specified device name. More...

 
def get_metric
 Gets a general runtime metric for dedicated hardware. More...

 
def get_config
 Gets a configuration dedicated to device behavior. More...

 
 

Class Attributes

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.

Detailed Description

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

Constructor & Destructor Documentation

§ __init__()

def ie_api.IECore.__init__ (   self,
  xml_config_file = "" 
)

Class constructor.

Parameters
xml_config_fileA full path to .xml file containing plugins configuration. If the parameter is not specified, the default configuration is handled automatically.
Returns
Instance of IECore class

Member Function Documentation

§ add_extension()

def ie_api.IECore.add_extension (   self,
  extension_path,
  device_name 
)

Loads extension library to the plugin with a specified device name.

Parameters
extension_pathPath to the extensions library file to load to a plugin
device_nameA 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")

§ get_config()

def ie_api.IECore.get_config (   self,
  device_name,
  config_name 
)

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_nameA name of a device to get a config value.
config_nameA 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()

def ie_api.IECore.get_metric (   self,
  device_name,
  metric_name 
)

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_nameA name of a device to get a metric value.
metric_nameA 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()

def ie_api.IECore.get_versions (   self,
  device_name 
)

Get a namedtuple object with versions of the plugin specified.

Parameters
device_nameName of the the registered plugin
Returns
Dictionary mapping a plugin name and Versions 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()

def ie_api.IECore.import_network (   self,
  str,
  model_file,
  str,
  device_name,
  config = None,
  int,
  num_requests = 1 
)

Creates an executable network from a previously exported network.

Parameters
device_nameName of device load executable network on
model_fileFull path to the location of the exported file
configA dictionary of plugin configuration keys and their values
num_requestsA 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_requsts=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()

def ie_api.IECore.load_network (   self,
  IENetwork,
  network,
  str,
  device_name,
  config = None,
  int,
  num_requests = 1 
)

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
networkA valid IENetwork instance
device_nameA device name of a target plugin
configA dictionary of plugin configuration keys and their values
num_requestsA 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()

def ie_api.IECore.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
networkA valid IENetwork instance
device_nameA device name of a target plugin
configA 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()

def ie_api.IECore.read_network (   self,
  model 
)

Reads a network from the Intermediate Representation (IR) and creates an IENetwork.

Parameters
modelA .xml file of the IR or string with IR.
weightsA .bin file of the IR. Depending on init_from_buffer value, can be a string path or bytes with file content.
init_from_bufferDefines 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()

def ie_api.IECore.register_plugin (   self,
  plugin_name,
  device_name 
)

Registers plugins specified in an .xml configuration file.

Parameters
plugin_nameA 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_nameA 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()

def ie_api.IECore.register_plugins (   self,
  xml_config_file 
)

Registers plugins specified in an .xml configuration file.

Parameters
xml_config_fileA 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()

def ie_api.IECore.set_config (   self,
  config,
  device_name 
)

Sets a configuration for a plugin.

Note
When specifying a key value of a config, the "KEY_" prefix is omitted.
Parameters
configa dictionary of configuration parameters as keys and their values
device_namea 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()

def ie_api.IECore.unregister_plugin (   self,
  device_name 
)

Unregisters a plugin with a specified device name.

Parameters
device_nameA device name of the plugin to unregister
Returns
None

Usage example:

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