Base Interface¶
The base interface for all argument groups.
Module: polygraphy.tools.args
- class ArgGroups(dct=None)¶
Bases:
InterfaceMaps argument group types to argument groups.
- class BaseArgs¶
Bases:
objectAdds a arguments to a command-line parser, and provides capabilities to create Polygraphy objects based on the arguments.
Child classes that add options must define a docstring that includes a section header for the argument group, a brief description which should complete the sentence: “Options related to …”, and finally, any dependencies:
Section Header: Description Depends on: - OtherArgs0 - OtherArgs1: <additional info: condition under which it is needed, or reason for dependency> <Optional Additional Documentation>
For example:
TensorRT Engine: loading TensorRT engines. Depends on: - ModelArgs - TrtLoadPluginsArgs - TrtLoadNetworkArgs: if building engines - TrtConfigArgs: if building engines - TrtSaveEngineBytesArgs: if allow_saving == True
The section header and description will be used to popluate the tool’s help output.
- add_parser_args(parser)¶
Add arguments to a command-line parser.
This method is guaranteed to only be called after register.
- Parameters:
parser (argparse.ArgumentParser) – The argument parser.
- add_to_script(script, *args, **kwargs) str¶
Adds code to the given script that performs the functionality provided by this argument group.
For example,
TrtConfigArgswould add a call toCreateConfig.This method is guaranteed to only be called after parse.
- Parameters:
script (polygraphy.tools.script.Script) – A script to which code should be added.
- Returns:
The name of the variable that was modified or added in the script.
- Return type:
str
- allows_abbreviation()¶
Whether to allow abbreviated options. When this is enabled, a prefix of an option can be used instead of specifying the entire option. For example, an
--iterationscould be specified with just--iter. This breaksargparse.REMAINDER, so any argument groups using that should disable this. The default implementation returns True.- Returns:
bool
- parse(args)¶
Parses relevant arguments from command-line arguments and populates corresponding attributes of this argument group.
This method is guaranteed to only be called after add_parser_args.
- Parameters:
args – Arguments provided by argparse.
- class BaseRunnerArgs¶
Bases:
BaseArgsSimilar to BaseArgs, but meant specifically for argument groups dealing with runners.
- add_to_script(script) str¶
- Returns:
The name of the list of runners in the script.
- Return type:
str
- get_extra_help_text() str¶
Returns any extra help text to display in the tool help output for this runner.
- get_name_opt() Tuple[str, str]¶
Returns a tuple containing a human readable name of the runner and the name of the command-line option (without leading dashes) that should be used to select the runner controlled by this argument group.
For example:
("TensorRT", "trt").