-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_runtime_variance.py
50 lines (34 loc) · 1.31 KB
/
test_runtime_variance.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import sys
import time
import onnx
import taso as ts
import numpy as np
from xflowrl.environment.hierarchical import HierarchicalEnvironment
def load_graph(filename):
return ts.load_onnx(filename)
def main(argv):
#graph_files = glob.glob('graphs/**/*.onnx', recursive=True)
graph_files = ['graphs/squeezenet1.1.onnx']
#graph_files = ['taso_optimized_graphs/squeezenet1.1.onnx']
#graph_files = ['/tmp/tmponnx.onnx']
skip_files = []#{'graphs/vgg16.onnx', 'graphs/inception_v2.onnx', 'graphs/resnet34v1.onnx'}
graphs = []
for graph_file in graph_files:
if graph_file in skip_files:
continue
print("Loading graph: {}".format(graph_file))
graphs.append((graph_file, load_graph(graph_file)))
if graph_file == 'graphs/squeezenet1.1.onnx':
break
#env = HierarchicalEnvironment(real_measurements=True)
for current_graph_file, current_graph in graphs:
#env.set_graph(current_graph)
# env.reset()
runtimes = []
for i in range(100):
if i % 10 == 0:
print("Measurement {}".format(i))
runtimes.append(current_graph.run_time_memorysafe())
print("Runtimes: {:.4f} ({:.4f})".format(np.mean(runtimes), np.std(runtimes)))
if __name__ == '__main__':
main(sys.argv)