forked from patflick/miopen-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalexnet.cpp
62 lines (50 loc) · 1.42 KB
/
alexnet.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
#include "miopen.hpp"
#include "tensor.hpp"
#include "utils.hpp"
#include "layers.hpp"
#include "multi_layers.hpp"
// implements AlexNet
void alexNet() {
TensorDesc input_dim(128, 3, 224, 224);
Sequential features(input_dim);
/* features */
features.addConv(64, 11, 2, 4);
features.addReLU();
features.addMaxPool(3, 0, 2);
features.addConv(192, 5, 2, 1);
features.addReLU();
features.addMaxPool(3, 0, 2);
features.addConv(384, 3, 1, 1);
features.addReLU();
features.addConv(256, 3, 1, 1);
features.addReLU();
features.addConv(256, 3, 1, 1);
features.addReLU();
features.addMaxPool(3, 0, 2);
DEBUG("Dims after Features: " << features.getOutputDesc());
/* classifier */
Sequential classifier(features.getOutputDesc());
// TODO Dropout
classifier.reshape(input_dim.n, 256 * 6 * 6, 1, 1);
classifier.addLinear(4096);
classifier.addReLU();
// TODO: Dropout
classifier.addLinear(4096);
classifier.addReLU();
classifier.addLinear(1000);
Model m(input_dim);
m.add(features);
m.add(classifier);
m.input.uniform(); // randomly initialize input
BenchmarkLogger::new_session("alex_net");
BenchmarkLogger::benchmark(m, 50);
}
int main(int argc, char *argv[])
{
device_init();
// enable profiling
CHECK_MIO(miopenEnableProfiling(mio::handle(), true));
alexNet();
miopenDestroy(mio::handle());
return 0;
}