Supported Simplified mode without provided config (#10049)

* Support Simplified mode without provided config

* Change data-source default location
This commit is contained in:
Liubov Talamanova 2022-02-03 10:56:25 +03:00 committed by GitHub
parent e7d8284e4d
commit b4206fe0a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 20 deletions

View File

@ -112,13 +112,14 @@ def get_common_argument_parser():
default=False,
help='Keep Convolution, Deconvolution and FullyConnected weights uncompressed')
data_free_opt = parser.add_argument_group('DataFreeEngine options')
data_free_opt.add_argument(
parser.add_argument(
'--data-source',
default='../../../pot_dataset',
help='Path to directory where synthetic dataset is located or will be generated and saved. '
'Default: `../../../pot_dataset`')
help='Valid for DataFree and Simplified modes. For Simplified mode path to dataset dir is required. '
'For DataFree mode specify path to directory '
'where syntetic dataset is located or will be generated and saved. '
'For DataFree mode default: `./pot_dataset`')
data_free_opt = parser.add_argument_group('DataFree mode options')
data_free_opt.add_argument(
'--shape',
@ -147,21 +148,23 @@ def get_common_argument_parser():
def check_dependencies(args):
if (args.quantize is not None and
(args.model is None or
args.weights is None or
args.ac_config is None and args.engine != 'data_free')):
raise ValueError(
'--quantize option requires model, weights, and AC config to be specified.')
if args.quantize is None and args.config is None:
raise ValueError(
'Either --config or --quantize option should be specified')
if args.quantize is not None and args.config is not None:
raise ValueError('Either --config or --quantize option should be specified')
if args.quantize is not None and (args.model is None or args.weights is None):
raise ValueError(
'--quantize option requires model and weights to be specified.')
if (args.quantize is not None and args.ac_config is None and
(args.engine == 'accuracy_checker' or args.engine is None)):
raise ValueError(
'--quantize option requires AC config to be specified '
'or --engine should be `data_free` or `simplified`.')
if args.quantize == 'accuracy_aware' and args.max_drop is None:
raise ValueError('For AccuracyAwareQuantization --max-drop should be specified')
if args.engine == 'data_free' and args.ac_config is not None:
raise ValueError('Either DataFree mode or AC config should be specified')
if args.config is None and args.engine == 'simplified' and args.data_source is None:
raise ValueError('For Simplified mode `--data-source` option should be specified')
check_extra_arguments(args, 'model')
check_extra_arguments(args, 'weights')
check_extra_arguments(args, 'preset')

View File

@ -39,6 +39,8 @@ def app(argv):
if args.engine:
config.engine['type'] = args.engine if args.engine else 'accuracy_checker'
if 'data_source' not in config.engine:
if args.data_source is None and config.engine.type == 'data_free':
args.data_source = 'pot_dataset'
config.engine['data_source'] = args.data_source
config.configure_params(args.ac_config)

View File

@ -310,7 +310,7 @@ class Config(Dict):
self._configure_ac_params()
self.engine.type = 'accuracy_checker'
elif engine.type == 'simplified' or engine.type == 'data_free':
if 'data_source' not in engine:
if engine.data_source is None:
raise KeyError(f'Missed data dir for {engine.type} engine')
self.engine.device = engine.device if engine.device else 'CPU'
engine.data_source = Path(engine.data_source)

View File

@ -20,12 +20,14 @@ def check_wrong_parametrs(argv):
test_params = [('', 'Either --config or --quantize option should be specified', ValueError),
('-e -m path_model', 'Either --config or --quantize option should be specified', ValueError),
('--quantize default -w path_weights -m path_model',
"--quantize option requires model, weights, "
"and AC config to be specified.", ValueError),
'--quantize option requires AC config to be specified '
'or --engine should be `data_free` or `simplified`.', ValueError),
('--quantize accuracy_aware -m path_model --ac-config path_config',
"--quantize option requires model, weights, "
"and AC config to be specified.", ValueError),
('-c path_config -m path_model', 'Either --config or --model option should be specified', ValueError)]
'--quantize option requires model and weights to be specified.', ValueError),
('-c path_config -m path_model', 'Either --config or --model option should be specified', ValueError),
('--quantize default -w path_weights -m path_model --engine simplified',
'For Simplified mode `--data-source` option should be specified', ValueError),
]
@pytest.mark.parametrize('st, match, error', test_params,
ids=['{}_{}_{}'.format(v[0], v[1], v[2]) for v in test_params])
def test_wrong_parametrs_cmd(st, match, error):