TensorRT  7.2.1.6
NVIDIA TensorRT
Looking for a C++ dev who knows TensorRT?
I'm looking for work. Hire me!
nvinfer1::utility Namespace Reference

Classes

struct  TRTOption
 TRTOption defines a command line option. More...
 
struct  TRTParsedArgs
 TRTParsedArgs is returned by getOptions after it has parsed a command line argument list (argv). More...
 

Functions

bool matches (const TRTOption &a, const TRTOption &b)
 Matching for TRTOptions is defined as follows: More...
 
int getTRTOptionIndex (const std::vector< TRTOption > &options, const TRTOption &opt)
 getTRTOptionIndex returns the index of a TRTOption in a vector of TRTOptions, -1 if not found. More...
 
std::string validateTRTOption (const std::set< char > &seenShortNames, const std::set< std::string > &seenLongNames, const TRTOption &opt)
 validateTRTOption will return a string containing an error message if options contain non-numeric characters, or if there are duplicate option names found. More...
 
std::string validateTRTOptions (const std::vector< TRTOption > &options)
 validateTRTOptions will return a string containing an error message if any options contain non-numeric characters, or if there are duplicate option names found. More...
 
TRTParsedArgs parseArgs (int argc, const char *const *argv, const std::vector< TRTOption > &options)
 parseArgs parses an argument list and returns a TRTParsedArgs with the fields set accordingly. More...
 
TRTParsedArgs getOptions (int argc, const char *const *argv, const std::vector< TRTOption > &options)
 Parse the input arguments passed to main() and extract options as well as positional arguments. More...
 

Function Documentation

◆ matches()

bool nvinfer1::utility::matches ( const TRTOption a,
const TRTOption b 
)

Matching for TRTOptions is defined as follows:

If A and B both have longName set, A matches B if and only if A.longName == B.longName and (A.shortName == B.shortName if both have short name set).

If A only has shortName set and B only has longName set, then A does not match B. It is assumed that when 2 TRTOptions are compared, one of them is the definition of a TRTOption in the input to getOptions. As such, if the definition only has shortName set, it will never be equal to a TRTOption that does not have shortName set (and same for longName).

If A and B both have shortName set but B does not have longName set, A matches B if and only if A.shortName == B.shortName.

If A has neither long or short name set, A matches B if and only if B has neither long or short name set.

Here is the caller graph for this function:

◆ getTRTOptionIndex()

int nvinfer1::utility::getTRTOptionIndex ( const std::vector< TRTOption > &  options,
const TRTOption opt 
)

getTRTOptionIndex returns the index of a TRTOption in a vector of TRTOptions, -1 if not found.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validateTRTOption()

std::string nvinfer1::utility::validateTRTOption ( const std::set< char > &  seenShortNames,
const std::set< std::string > &  seenLongNames,
const TRTOption opt 
)

validateTRTOption will return a string containing an error message if options contain non-numeric characters, or if there are duplicate option names found.

Otherwise, returns the empty string.

Here is the caller graph for this function:

◆ validateTRTOptions()

std::string nvinfer1::utility::validateTRTOptions ( const std::vector< TRTOption > &  options)

validateTRTOptions will return a string containing an error message if any options contain non-numeric characters, or if there are duplicate option names found.

Otherwise, returns the empty string.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parseArgs()

TRTParsedArgs nvinfer1::utility::parseArgs ( int  argc,
const char *const *  argv,
const std::vector< TRTOption > &  options 
)

parseArgs parses an argument list and returns a TRTParsedArgs with the fields set accordingly.

Assumes that options is validated. ErrMsg will be set if:

  • an argument is null
  • an argument is empty
  • an argument does not have option (i.e. "-" and "--")
  • a short argument has more than 1 character
  • the last argument in the list requires a value
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOptions()

TRTParsedArgs nvinfer1::utility::getOptions ( int  argc,
const char *const *  argv,
const std::vector< TRTOption > &  options 
)

Parse the input arguments passed to main() and extract options as well as positional arguments.

Options are supposed to be passed to main() with a preceding hyphen '-'.

If there is a single preceding hyphen, there should be exactly 1 character after the hyphen, which is interpreted as the option.

If there are 2 preceding hyphens, the entire argument (without the hyphens) is interpreted as the option.

If the option requires a value, the next argument is used as the value.

Positional arguments must not start with a hyphen.

If an argument requires a value, the next argument is interpreted as the value, even if it is the form of a valid option (i.e. –foo –bar will store "--bar" as a value for option "foo" if "foo" requires a value). We also support –name=value syntax. In this case, 'value' would be used as the value, NOT the next argument.

For options: { { 'a', "", false }, { 'b', "", false }, { 0, "cee", false }, { 'd', "", true }, { 'e', "", true }, { 'f', "foo", true } }

./main hello world -a -a –cee -d 12 -f 34 and ./main hello world -a -a –cee -d 12 –foo 34

will result in:

TRTParsedArgs { errMsg: "", values: { { 2, {} }, { 0, {} }, { 1, {} }, { 1, {"12"} }, { 0, {} }, { 1, {"34"} } } positionalArgs: {"hello", "world"}, }

Non-POSIX behavior:

  • Does not support "-abcde" as a shorthand for "-a -b -c -d -e". Each option must have its own hyphen prefix.
  • Does not support -e12 as a shorthand for "-e 12". Values MUST be whitespace-separated from the option it is for.
Parameters
[in]argcThe number of arguments passed to main (including the file name, which is disregarded)
[in]argvThe arguments passed to main (including the file name, which is disregarded)
[in]optionsList of TRTOptions to parse
Returns
TRTParsedArgs. See TRTParsedArgs documentation for descriptions of the fields.
Here is the call graph for this function: