-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.cpp
84 lines (68 loc) · 2.01 KB
/
test.cpp
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
#include <iostream>
#include <fstream>
#include <cmath>
#include "Utils.h"
#include "RoboDNN.h"
#include <ctime>
int main()
{
// Create random image
int imgCnt = 100;
int W = 512, H = 384;
std::vector<float> in(W*H*3);
int rowoffs = 0;
int choffs = W*H;
for (int i = 0; i < H; i++)
{
for (int j = 0; j < W; j++)
{
in[rowoffs + j] = rand()%255;
in[choffs + rowoffs + j] = rand()%255;
in[2*choffs + rowoffs + j] = rand()%255;
}
rowoffs += W;
}
float runs[4];
for (int j = 0; j < 4; j++) {
std::cout << "Running net " << j << std::endl;
std::string cfg = "robo.cfg";
if(j==3)
cfg = "robo-hr.cfg";
std::string weight = "";
switch (j) {
case 0:
weight = "weightsFT.dat";
break;
case 1:
weight = "weights88.dat";
break;
case 2:
weight = "weights93.dat";
break;
case 3:
weight = "weights93.dat";
break;
default:
break;
}
// Construct net
Network net("config/", cfg, weight);
double elapsed = 0;
for (int i = 0; i < imgCnt; i++)
{
clock_t start = clock();
float *data_f = net.forward(in.data());
std::vector<float> out(data_f, data_f + net.getOutCnt());
clock_t finish = clock();
//std::cout << "Time: " << (finish - start).count() / 1000000.0 << " ms\n\n";
elapsed += double(finish - start) / CLOCKS_PER_SEC * 1000.0;
}
runs[j] = elapsed/(imgCnt);
}
std::cout << "Results" << std::endl;
std::cout << runs[0] << std::endl;
std::cout << runs[1] << std::endl;
std::cout << runs[2] << std::endl;
std::cout << runs[3] << std::endl;
return 0;
}