MCPcopy Create free account
hub / github.com/PaddlePaddle/PaddleDetection / PaddleInferBenchmark

Class PaddleInferBenchmark

deploy/python/benchmark_utils.py:27–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25
26
27class PaddleInferBenchmark(object):
28 def __init__(self,
29 config,
30 model_info: dict={},
31 data_info: dict={},
32 perf_info: dict={},
33 resource_info: dict={},
34 **kwargs):
35 """
36 Construct PaddleInferBenchmark Class to format logs.
37 args:
38 config(paddle.inference.Config): paddle inference config
39 model_info(dict): basic model info
40 {'model_name': 'resnet50'
41 'precision': 'fp32'}
42 data_info(dict): input data info
43 {'batch_size': 1
44 'shape': '3,224,224'
45 'data_num': 1000}
46 perf_info(dict): performance result
47 {'preprocess_time_s': 1.0
48 'inference_time_s': 2.0
49 'postprocess_time_s': 1.0
50 'total_time_s': 4.0}
51 resource_info(dict):
52 cpu and gpu resources
53 {'cpu_rss': 100
54 'gpu_rss': 100
55 'gpu_util': 60}
56 """
57 # PaddleInferBenchmark Log Version
58 self.log_version = "1.0.3"
59
60 # Paddle Version
61 self.paddle_version = paddle.__version__
62 self.paddle_commit = paddle.__git_commit__
63 paddle_infer_info = paddle_infer.get_version()
64 self.paddle_branch = paddle_infer_info.strip().split(': ')[-1]
65
66 # model info
67 self.model_info = model_info
68
69 # data info
70 self.data_info = data_info
71
72 # perf info
73 self.perf_info = perf_info
74
75 try:
76 # required value
77 self.model_name = model_info['model_name']
78 self.precision = model_info['precision']
79
80 self.batch_size = data_info['batch_size']
81 self.shape = data_info['shape']
82 self.data_num = data_info['data_num']
83
84 self.inference_time_s = round(perf_info['inference_time_s'], 4)

Callers 5

mainFunction · 0.90
bench_logFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected