#########################################################
# Copyright (C) 2022 SiMa Technologies, Inc.
#
# This material is SiMa proprietary and confidential.
#
# This material may not be copied or distributed without
# the express prior written permission of SiMa.
#
# All rights reserved.
#########################################################
# Code owner: Nenad Nikolic
#########################################################
"""
The command line argument parser. make_parser returns
a parser which collects command line parameters
and puts them in a data structure.
"""
import argparse
import afe.driver.cli.commands as commands
[docs]
def parse_arguments() -> argparse.Namespace:
"""
Create an argument parser for parsing command line input.
TODO: Document the returned namespace.
"""
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subparser_name')
_make_parser_compile(subparsers)
return parser.parse_args()
def _make_parser_compile(subparsers):
parser_compile = subparsers.add_parser('compile')
parser_compile.add_argument("--framework", help="Framework of the model, i.e. tensorflow, pytorch etc.")
parser_compile.add_argument("--input_path", help="Absolute path for config file", required=True)
parser_compile.add_argument("--layout", help="Data layout of model inputs and outputs", choices=['NCHW', 'NHWC'])
parser_compile.add_argument("--param_names", help="Names of model inputs as a comma-separated"
"string, for example \"color,depth\"")
parser_compile.add_argument("--param_shapes", help="Shapes of model inputs as a "
"comma-separated string of hyphenated "
"tuples, for example \"50-50-3,25-25-1\"")
parser_compile.add_argument("--param_dtypes", help="Numeric types of model inputs as a "
"comma-separated string, for example \"float32,int8\"")
parser_compile.add_argument('--no-convert_layout', dest='convert_layout', action='store_false')
parser_compile.add_argument('--graph_partition', dest='graph_partition', action='store_true')
parser_compile.add_argument('--no-graph_partition', dest='graph_partition', action='store_false')
parser_compile.add_argument('--quantized', dest='quantized', action='store_true')
parser_compile.add_argument('--no-quantized', dest='quantized', action='store_false')
parser_compile.set_defaults(quantized=False)
parser_compile.add_argument("--output_path", help="Output path for results of compilation")
parser_compile.set_defaults(func=commands.compile_command)