Support of unnamed saved_model_dir in MO Python API (#16542)
* Added support of unnamed saved_model_dir. * Switch TF2 layer tests for unnamed saved_model_dir. * Added test. * Correction of comment. * Removed unnecessary pytest mark. * Code correction, added comment.
This commit is contained in:
1 parent
4a997de4a3
commit
dc2fa65224
2 files changed
+40
-3
No files matched your search
@@ -808,6 +808,22 @@ def pack_params_to_args_namespace(args: dict, cli_parser: argparse.ArgumentParse
|
||||
return argv
|
||||
|
||||
|
||||
def update_args_for_saved_model_dir(args: dict):
|
||||
"""
|
||||
If directory is set in 'input_model' argument, the directory is considered as TF saved model.
|
||||
In this case this method updates args and moves saved model directory to 'saved_model_dir' param.
|
||||
:param args: dictionary with arguments from user
|
||||
"""
|
||||
if 'saved_model_dir' in args and args['saved_model_dir'] is not None and \
|
||||
'input_model' in args and args['input_model'] is not None:
|
||||
raise Error("Both --input_model and --saved_model_dir are defined. "
|
||||
"Please specify either input_model or saved_model_dir directory.")
|
||||
|
||||
if 'input_model' in args and isinstance(args['input_model'], (str, Path)) and os.path.isdir(args['input_model']):
|
||||
args['saved_model_dir'] = args['input_model']
|
||||
args['input_model'] = None
|
||||
|
||||
|
||||
def _convert(cli_parser: argparse.ArgumentParser, framework, args):
|
||||
if 'help' in args and args['help']:
|
||||
show_mo_convert_help()
|
||||
@@ -839,6 +855,8 @@ def _convert(cli_parser: argparse.ArgumentParser, framework, args):
|
||||
args['input_model'] = decoder
|
||||
args["framework"] = "pytorch"
|
||||
|
||||
update_args_for_saved_model_dir(args)
|
||||
|
||||
argv = pack_params_to_args_namespace(args, cli_parser)
|
||||
|
||||
argv.feManager = FrontEndManager()
|
||||
|
||||
Reference in new issue
Block a user