-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark_intel_single_sync.py
117 lines (99 loc) · 4.25 KB
/
benchmark_intel_single_sync.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import gc
from pathlib import Path
from openvino.inference_engine import IECore
import os.path
import numpy as np
import time
import csv
import common_benchmark_definitions as common
infCore=IECore()
measurements_openvino="OpenVINO-Measurements"
if not os.path.isdir(measurements_openvino): os.mkdir(measurements_openvino)
iterations=common.iterations
#350-> python braucht 10 GB RAm
global_iterations=common.global_iterations
nets_to_run=common.tf_net_names #[:12] #memory problems in many_conv2d, at least at the CPU
#openvino_nets=[startNet(x) for x in nets_to_run]
#for target in ["GPU","CPU",]:#"GPU","CPU",,"CPU","MYRIAD"
#
# measurements=dict()
# measurements2=dict()
# for name in nets_to_run:
# measurements["newData("+name+")"]=[]
# measurements["noData("+name+")"]=[]
# measurements2[name]=[]
#
# for l in range(global_iterations):
# for i in range(len(nets_to_run)):
# loaded_net=common.startOpenvinoNet(nets_to_run[i],infCore,target)
# #network_input="input_1"
# network_input=next(iter(loaded_net.input_info))
#
# data_format=[common.iterations_single]
# data_format.extend(loaded_net.input_info[network_input].tensor_desc.dims)
#
# data=common.getOpenvinoExampelData(data_format)
# #supply new data with every inference
# for j in range(common.iterations_single):
# start=time.perf_counter()
# loaded_net.infer({network_input:data[0]})
# end=time.perf_counter()
# measurements["newData("+nets_to_run[i]+")"].append(end-start)
# start2=time.perf_counter()
# loaded_net.infer()
# end2=time.perf_counter()
# measurements2[nets_to_run[i]].append((end-start)-(end2-start2))
#
# #do not supply new data with every inference
# for j in range(common.iterations_single):
# start=time.perf_counter()
# loaded_net.infer()
# end=time.perf_counter()
# measurements["noData("+nets_to_run[i]+")"].append(end-start)
#
# data=None
# gc.collect()
#
# print(nets_to_run[i])
#
# common.writeResults(target,measurements2,"setData","openvino","sync")
# common.writeResults(target,measurements,"single","openvino","sync")
for target in ["GPU","CPU","MYRIAD"]:#"GPU","CPU",,"CPU","MYRIAD"
print(target)
measurements=dict()
#measurements2=dict()
for name in nets_to_run:
measurements[name]=[]
#measurements2["min("+name+")"]=[]
#measurements2["max("+name+")"]=[]
#measurements2["avg("+name+")"]=[]
#measurements2["std("+name+")"]=[]
for l in range(global_iterations):
print(l)
for i in range(len(nets_to_run)):
loaded_net=common.startOpenvinoNet(nets_to_run[i],infCore,target,1)
#network_input="input_1"
network_input=next(iter(loaded_net.input_info))
data_format=[common.iterations_single]
data_format.extend(loaded_net.input_info[network_input].tensor_desc.dims)
data=common.getOpenvinoExampelData(data_format)
#supply new data with every inference
#min=2147483647
#max=-1
#list_measurements=[]
for j in range(common.iterations_single):
start=time.perf_counter()
loaded_net.infer({network_input:data[j]})
end=time.perf_counter()
measured_time=end-start
measurements[nets_to_run[i]].append(measured_time)
#measurements2["min("+nets_to_run[i]+")"].append(min)
#measurements2["max("+nets_to_run[i]+")"].append(max)
#m=np.array(list_measurements)
#measurements2["std("+nets_to_run[i]+")"].append(np.std(m))
#measurements2["avg("+nets_to_run[i]+")"].append(np.average(m))
data=None
gc.collect()
print(nets_to_run[i])
#common.writeResults(target,measurements2,"statistic","openvino","sync")
common.writeResults(target,measurements,"single","openvino","sync")