2 Copyright (C) 2018-2019 Intel Corporation
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
21 from functools import partial
22 from argparse import ArgumentParser
23 from typing import Union
25 from ..accuracy_checker.accuracy_checker.config import ConfigReader
26 from ..accuracy_checker.accuracy_checker.utils import get_path
27 from ..network import Network
29 from .configuration import Configuration
30 from .logging import info
33 class CommandLineReader:
35 Class for parsing input config
39 args, unknown_args = CommandLineReader.__build_arguments_parser().parse_known_args()
41 info("unknown command line arguments: {0}".format(unknown_args))
43 args.target_framework = "dlsdk"
46 merged_config = ConfigReader.merge(args)
47 launcher = merged_config['models'][0]['launchers'][0]
49 batch_size = args.batch_size if args.batch_size else (launcher['batch'] if 'batch' in launcher else None)
51 with Network(str(launcher['model']), str(launcher['weights'])) as network:
52 batch_size = network.ie_network.batch_size
55 config = merged_config,
56 model = str(launcher['model']),
57 weights = str(launcher['weights']),
58 cpu_extension = (str(launcher['cpu_extensions']) if 'cpu_extensions' in launcher else None),
59 gpu_extension = (str(launcher['gpu_extensions']) if 'gpu_extensions' in launcher else None),
60 device = launcher['device'],
61 benchmark_iterations_count = args.benchmark_iterations_count)
64 def __build_arguments_parser():
65 parser = ArgumentParser(description='openvino.tools.benchmark')
68 '-d', '--definitions',
69 help='Optional. Path to the YML file with definitions',
76 help='Required. Path to the YML file with local configuration',
82 help='Optional. Prefix path to the models and weights',
83 type=partial(get_path, is_directory=True),
84 default=pathlib.Path.cwd(),
89 help='Optional. prefix path to the data source',
90 type=partial(get_path, is_directory=True),
91 default=pathlib.Path.cwd(),
95 '-a', '--annotations',
96 help='Optional. prefix path to the converted annotations and datasets meta data',
97 type=partial(get_path, is_directory=True),
98 default=pathlib.Path.cwd(),
102 '-e', '--extensions',
103 help='Optional. Prefix path to extensions folder',
104 type=partial(get_path, is_directory=True),
105 default=pathlib.Path.cwd(),
109 '--cpu_extensions_mode',
110 help='Optional. specified preferable set of processor instruction for automatic searching cpu extension lib',
112 choices=['avx2', 'sse4'])
115 '-b', '--bitstreams',
116 help='Optional. prefix path to bitstreams folder',
117 type=partial(get_path, is_directory=True),
118 default=pathlib.Path.cwd(),
122 '-C', '--converted_models', '--converted-models',
123 help='Optional. directory to store Model Optimizer converted models. Used for DLSDK launcher only',
124 type=partial(get_path, is_directory=True),
125 default=pathlib.Path.cwd(),
129 '-td', '--target_devices', '--target-devices',
130 help='Optional. Space-separated list of devices for infer',
136 '-tt', '--target_tags', '--target-tags',
137 help='Optional. Space-separated list of launcher tags for infer',
143 help='Optional. Batch size value. If not specified, the batch size value is determined from IR',
149 '--benchmark_iterations_count',
150 help='Optional. Benchmark itertations count. (1000 is default)',