MCPcopy Create free account
hub / github.com/NVIDIA/TensorRT / parse_args

Function parse_args

demo/BERT/inference_varseqlen.py:41–84  ·  view source on GitHub ↗

Parse command line arguments

()

Source from the content-addressed store, hash-verified

39TRT_LOGGER = trt.Logger(trt.Logger.INFO)
40
41def parse_args():
42 """
43 Parse command line arguments
44 """
45 parser = argparse.ArgumentParser(description=__doc__)
46 parser.add_argument('-e', '--engine',
47 help='Path to BERT TensorRT engine')
48 parser.add_argument('-p', '--passage', nargs='*',
49 help='Text for paragraph/passage for BERT QA',
50 default='')
51 parser.add_argument('-pf', '--passage-file',
52 help='File containing input passage',
53 default='')
54 parser.add_argument('-q', '--question', nargs='*',
55 help='Text for query/question for BERT QA',
56 default='')
57 parser.add_argument('-qf', '--question-file',
58 help='File containing input question',
59 default='')
60 parser.add_argument('-sq', '--squad-json',
61 help='SQuAD json file',
62 default='')
63 parser.add_argument('-o', '--output-prediction-file',
64 help='Output prediction file for SQuAD evaluation',
65 default='./predictions.json')
66 parser.add_argument('-v', '--vocab-file',
67 help='Path to file containing entire understandable vocab')
68 parser.add_argument('-s', '--sequence-length',
69 help='The sequence length to use. Defaults to 128',
70 default=128, type=int)
71 parser.add_argument('--max-query-length',
72 help='The maximum length of a query in number of tokens. Queries longer than this will be truncated',
73 default=64, type=int)
74 parser.add_argument('--max-answer-length',
75 help='The maximum length of an answer that can be generated',
76 default=30, type=int)
77 parser.add_argument('--n-best-size',
78 help='Total number of n-best predictions to generate in the nbest_predictions.json output file',
79 default=20, type=int)
80 parser.add_argument('--doc-stride',
81 help='When splitting up a long document into chunks, what stride to take between chunks',
82 default=128, type=int)
83 args, _ = parser.parse_known_args()
84 return args
85
86if __name__ == '__main__':
87 args = parse_args()

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected