-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark_backend.py
More file actions
30 lines (20 loc) · 1.02 KB
/
benchmark_backend.py
File metadata and controls
30 lines (20 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""Common API for running benchmarks on different platforms"""
import importlib
class BackendManager():
""""""
def __init__(self, platform):
# Load backend for given platform
if platform == 'nvidia':
self.executer = importlib.import_module('nvidia.engine_executer')
else:
raise NotImplementedError('Platform {} is currently not supported'.format(platform))
def benchmark_model(self, config, path=None):
"""Benchmark a model defined by the given config on a given platform"""
# Run model
to_gpu_time, infer_time, from_gpu_time = self.executer.run_model(config, path)
return (to_gpu_time, infer_time, from_gpu_time)
def benchmark_model_avg(self, config, nr_runs, path=None):
"""Benchmark a model defined by the given config on a given platform"""
# Run model
to_gpu_time, infer_time, from_gpu_time = self.executer.run_model_multiple(config, nr_runs, path)
return (to_gpu_time, infer_time, from_gpu_time)