-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbenchmark_intel_avg_sync.py
61 lines (49 loc) · 2.13 KB
/
benchmark_intel_avg_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
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","MYRIAD"]:#"GPU","CPU",
print(target)
measurements=dict()
for name in nets_to_run:
measurements["first("+name+")"]=[]
measurements["avgTail("+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=[iterations]
data_format.extend(loaded_net.input_info[network_input].tensor_desc.dims)
#res2=[]
data=common.getOpenvinoExampelData(data_format)
#first inference
start_first=time.perf_counter()
loaded_net.infer({network_input:data[0]})
end_first=time.perf_counter()
measurements["first("+nets_to_run[i]+")"].append(end_first-start_first)
#measure time start
start=time.perf_counter()
for j in range(1,iterations):
loaded_net.infer({network_input:data[j]})
end=time.perf_counter()
# get the request, measure time https://github.com/openvinotoolkit/openvino/blob/master/tools/benchmark_tool/openvino/tools/benchmark/benchmark.py
#measure time end
data=None
gc.collect()
measurements["avgTail("+nets_to_run[i]+")"].append((end-start)/(iterations-1))
print(nets_to_run[i])
common.writeResults(target,measurements,"avg","openvino","sync")