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

Method execute

demo/HuggingFace/run.py:153–209  ·  view source on GitHub ↗
(self, args: argparse.Namespace)

Source from the content-addressed store, hash-verified

151 GENERAL_HEADERS = ["script", "accuracy"]
152
153 def execute(self, args: argparse.Namespace):
154 compare_group = []
155 if args.compare is None:
156 compare_group = self.PER_NETWORK_SCRIPTS
157 else:
158 compare_group = args.compare
159
160 if len(compare_group) <= 1:
161 G_LOGGER.error(
162 "Comparison command must have atleast two groups to compare to."
163 )
164 exit()
165
166 results = []
167 # Get the parser for inference script which is a superset
168 module = None
169 try:
170 module = self.load_script(self.TRT_SCRIPT_NAME, args)
171 except ModuleNotFoundError as e:
172 print("Unable to do comparison. TRT script not yet supported.")
173 exit(1)
174
175 nconfig = module.RUN_CMD.config
176 nconfig.MetadataClass.add_inference_args(self.parser)
177 self.parser.parse_known_args()
178
179 results = []
180 # It is possible certain scripts are not implemented
181 # Allow the results to generate even if script does not exist.
182 modified_compare_group = []
183 for g in compare_group:
184 cwd = os.getcwd()
185 try:
186 print()
187 print("Collecting Data for {}".format(g))
188 os.chdir(args.network)
189 module = self.load_script(g, args)
190 module.RUN_CMD._parser = self.parser
191 results.append(module.RUN_CMD())
192 modified_compare_group.append(g)
193 except ModuleNotFoundError as e:
194 print("{} is not valid, the demo does not support this script yet. Ignoring.".format(g))
195
196 finally:
197 os.chdir(cwd)
198
199 headers, rows = process_per_result_entries(modified_compare_group, results)
200 # Rows are grouped by input, flatten to show as one large table
201 flattened_rows = [r for input_row in rows.values() for r in input_row]
202 print()
203 print(tabulate(flattened_rows, headers=headers))
204
205 headers, rows = process_results(modified_compare_group, results, nconfig)
206 print()
207 print(tabulate(rows, headers=headers))
208
209 return 0
210

Callers

nothing calls this directly

Calls 8

process_resultsFunction · 0.90
printFunction · 0.85
load_scriptMethod · 0.80
errorMethod · 0.45
add_inference_argsMethod · 0.45
appendMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected