mindspore_lite.RunnerConfig

class mindspore_lite.RunnerConfig(context=None, workers_num=None, config_info=None, config_path=None)[source]

RunnerConfig Class defines runner config of one or more servables. The class can be used to make model parallel runner which corresponds to the service provided by a model. The client sends inference tasks and receives inference results through server.

Parameters
  • context (Context, optional) – Define the context used to store options during execution. Default: None.

  • workers_num (int, optional) – the num of workers. Default: None.

  • config_info (dict{str, dict{str, str}}, optional) – Nested map for passing model weight paths. e.g. {“weight”: {“weight_path”: “/home/user/weight.cfg”}}. Default: None. key currently supports [“weight”]; value is in dict format, key of it currently supports [“weight_path”], value of it is the path of weight, e.g. “/home/user/weight.cfg”.

  • config_path (str, optional) – Define the config path. Default: None.

Raises
  • TypeErrorcontext is neither a Context nor None.

  • TypeErrorworkers_num is neither an int nor None.

  • TypeErrorconfig_info is neither a dict nor None.

  • TypeErrorconfig_info is a dict, but the key is not str.

  • TypeErrorconfig_info is a dict, the key is str, but the value is not dict.

  • TypeErrorconfig_info is a dict, the key is str, the value is dict, but the key of value is not str.

  • TypeErrorconfig_info is a dict, the key is str, the value is dict, the key of the value is str, but the value of the value is not str.

  • ValueErrorworkers_num is an int, but it is less than 0.

  • TypeErrorconfig_path is neither a str nor None.

  • ValueErrorconfig_path does not exist.

Examples

>>> # only for serving inference
>>> import mindspore_lite as mslite
>>> context = mslite.Context()
>>> context.append_device_info(mslite.CPUDeviceInfo())
>>> config_info = {"weight": {"weight_path": "path of model weight"}}
>>> runner_config = mslite.RunnerConfig(context=context, workers_num=0, config_info=config_info,
                                    config_path="file.txt")
>>> print(runner_config)
workers num: 0,
context: 0,
config info: weight: weight_path: path of model weight,
config path: file.txt.