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

Method run_framework

demo/HuggingFace/T5/frameworks.py:285–332  ·  view source on GitHub ↗

Main entry point of our function which compiles and generates our model data.

(
        self,
        metadata: NetworkMetadata,
        network_input: List[str],
        working_directory: str,
        keep_onnx_model: bool,
        keep_pytorch_model: bool,
        timing_profile: TimingProfile,
        use_cpu: bool = False,
        batch_size: int = 1,
        args: object = None,
        benchmarking_mode: bool = False,
        perplexity_reference: List[str] = None,
    )

Source from the content-addressed store, hash-verified

283 return perplexity
284
285 def run_framework(
286 self,
287 metadata: NetworkMetadata,
288 network_input: List[str],
289 working_directory: str,
290 keep_onnx_model: bool,
291 keep_pytorch_model: bool,
292 timing_profile: TimingProfile,
293 use_cpu: bool = False,
294 batch_size: int = 1,
295 args: object = None,
296 benchmarking_mode: bool = False,
297 perplexity_reference: List[str] = None,
298 ) -> Union[List[NetworkResult], BenchmarkingResult]:
299 """
300 Main entry point of our function which compiles and generates our model data.
301 """
302 inference_results = []
303 ppl_results = []
304 workspace = NNFolderWorkspace(
305 self.config.network_name, metadata, working_directory
306 )
307 try:
308 network_fpaths = self.generate_and_download_framework(metadata, workspace)
309 if not benchmarking_mode:
310 for ninput in network_input:
311 inference_results.append(
312 self.execute_inference(
313 metadata, network_fpaths, ninput, timing_profile, use_cpu, batch_size, args.num_beams
314 )
315 )
316 if perplexity_reference is not None:
317 assert len(network_input) == len(perplexity_reference), "Encoder and decoder inputs must pair up"
318 for ei, di in zip(network_input, perplexity_reference):
319 ppl_results.append(
320 self.execute_calculate_perplexity(
321 metadata, network_fpaths, ei, di
322 )
323 )
324 else:
325 benchmarking_args = T5BenchmarkingArgs(args.input_seq_len, args.output_seq_len)
326 inference_results = self.execute_inference(
327 metadata, network_fpaths, None, timing_profile, use_cpu, batch_size, args.num_beams, True, benchmarking_args
328 )
329 finally:
330 self.cleanup(workspace, keep_onnx_model, keep_pytorch_model)
331
332 return inference_results, ppl_results
333
334
335# Entry point

Callers

nothing calls this directly

Calls 6

execute_inferenceMethod · 0.95
cleanupMethod · 0.95
NNFolderWorkspaceClass · 0.90
appendMethod · 0.45

Tested by

no test coverage detected