yolo test

This commit is contained in:
Francesco Gatti
2017-08-01 17:12:29 +02:00
parent b94931f9f7
commit 1cfe70365f
6 changed files with 144 additions and 16 deletions
+6 -6
View File
@@ -2,10 +2,10 @@
#include "tkdnn.h"
const char *input_bin = "../tests/mnist/input.bin";
const char *c0_bin = "../tests/mnist/layers/Convolution0.bin";
const char *c1_bin = "../tests/mnist/layers/Convolution1.bin";
const char *d2_bin = "../tests/mnist/layers/InnerProduct2.bin";
const char *d3_bin = "../tests/mnist/layers/InnerProduct3.bin";
const char *c0_bin = "../tests/mnist/layers/c0.bin";
const char *c1_bin = "../tests/mnist/layers/c1.bin";
const char *d2_bin = "../tests/mnist/layers/d2.bin";
const char *d3_bin = "../tests/mnist/layers/d3.bin";
const char *output_bin = "../tests/mnist/output.bin";
int main() {
@@ -14,9 +14,9 @@ int main() {
tkDNN::Network net;
tkDNN::dataDim_t dim(1, 1, 28, 28, 1);
tkDNN::Layer *l;
l = new tkDNN::Conv2d (&net, dim, 20, 5, 5, 1, 1, 1, 1, c0_bin);
l = new tkDNN::Conv2d (&net, dim, 20, 5, 5, 1, 1, 0, 0, c0_bin);
l = new tkDNN::Pooling (&net, l->output_dim, 2, 2, 2, 2, tkDNN::POOLING_MAX);
l = new tkDNN::Conv2d (&net, l->output_dim, 50, 5, 5, 1, 1, 1, 1, c1_bin);
l = new tkDNN::Conv2d (&net, l->output_dim, 50, 5, 5, 1, 1, 0, 0, c1_bin);
l = new tkDNN::Pooling (&net, l->output_dim, 2, 2, 2, 2, tkDNN::POOLING_MAX);
l = new tkDNN::Dense (&net, l->output_dim, 500, d2_bin);
l = new tkDNN::Activation (&net, l->output_dim, CUDNN_ACTIVATION_RELU);
+5 -5
View File
@@ -2,9 +2,9 @@
#include "tkdnn.h"
const char *input_bin = "../tests/test/input.bin";
const char *c0_bin = "../tests/test/layers/conv0.bin";
const char *c1_bin = "../tests/test/layers/conv1.bin";
const char *d2_bin = "../tests/test/layers/dense2.bin";
const char *c0_bin = "../tests/test/layers/c0.bin";
const char *c1_bin = "../tests/test/layers/c1.bin";
const char *d2_bin = "../tests/test/layers/d2.bin";
const char *output_bin = "../tests/test/output.bin";
int main() {
@@ -13,9 +13,9 @@ int main() {
tkDNN::Network net;
tkDNN::dataDim_t dim(1, 1, 10, 10, 1);
tkDNN::Layer *l;
l = new tkDNN::Conv2d (&net, dim, 2, 4, 4, 2, 2, 1, 1, c0_bin);
l = new tkDNN::Conv2d (&net, dim, 2, 4, 4, 2, 2, 0, 0, c0_bin);
l = new tkDNN::Activation (&net, l->output_dim, CUDNN_ACTIVATION_RELU);
l = new tkDNN::Conv2d (&net, l->output_dim, 4, 2, 2, 1, 1, 1, 1, c1_bin);
l = new tkDNN::Conv2d (&net, l->output_dim, 4, 2, 2, 1, 1, 0, 0, c1_bin);
l = new tkDNN::Activation (&net, l->output_dim, CUDNN_ACTIVATION_RELU);
l = new tkDNN::Flatten (&net, l->output_dim);
l = new tkDNN::Dense (&net, l->output_dim, 4, d2_bin);
+125
View File
@@ -0,0 +1,125 @@
#include<iostream>
#include "tkdnn.h"
const char *input_bin = "../tests/yolo/layers/input.bin";
const char *c0_bin = "../tests/yolo/layers/c0.bin";
const char *c2_bin = "../tests/yolo/layers/c2.bin";
const char *c4_bin = "../tests/yolo/layers/c4.bin";
const char *c5_bin = "../tests/yolo/layers/c5.bin";
const char *c6_bin = "../tests/yolo/layers/c6.bin";
const char *c8_bin = "../tests/yolo/layers/c8.bin";
const char *c9_bin = "../tests/yolo/layers/c9.bin";
const char *c10_bin = "../tests/yolo/layers/c10.bin";
const char *c12_bin = "../tests/yolo/layers/c12.bin";
const char *c13_bin = "../tests/yolo/layers/c13.bin";
const char *c14_bin = "../tests/yolo/layers/c14.bin";
const char *c15_bin = "../tests/yolo/layers/c15.bin";
const char *c16_bin = "../tests/yolo/layers/c16.bin";
const char *c18_bin = "../tests/yolo/layers/c18.bin";
const char *c19_bin = "../tests/yolo/layers/c19.bin";
const char *c20_bin = "../tests/yolo/layers/c20.bin";
const char *c21_bin = "../tests/yolo/layers/c21.bin";
const char *c22_bin = "../tests/yolo/layers/c22.bin";
const char *c23_bin = "../tests/yolo/layers/c23.bin";
const char *c24_bin = "../tests/yolo/layers/c24.bin";
const char *c26_bin = "../tests/yolo/layers/c26.bin";
const char *c29_bin = "../tests/yolo/layers/c29.bin";
const char *c30_bin = "../tests/yolo/layers/c30.bin";
const char *output_bin = "../tests/yolo/layers/output.bin";
int main() {
// Network layout
tkDNN::Network net;
tkDNN::dataDim_t dim(1, 3, 608, 608, 1);
tkDNN::Layer *l;
l = new tkDNN::Conv2d (&net, dim, 32, 3, 3, 1, 1, 1, 1, c0_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Pooling (&net, l->output_dim, 2, 2, 2, 2, tkDNN::POOLING_MAX);
l = new tkDNN::Conv2d (&net, l->output_dim, 64, 3, 3, 1, 1, 1, 1, c2_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Pooling (&net, l->output_dim, 2, 2, 2, 2, tkDNN::POOLING_MAX);
l = new tkDNN::Conv2d (&net, l->output_dim, 128, 3, 3, 1, 1, 1, 1, c4_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Conv2d (&net, l->output_dim, 64, 1, 1, 1, 1, 0, 0, c5_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Conv2d (&net, l->output_dim, 128, 3, 3, 1, 1, 1, 1, c6_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Pooling (&net, l->output_dim, 2, 2, 2, 2, tkDNN::POOLING_MAX);
l = new tkDNN::Conv2d (&net, l->output_dim, 256, 3, 3, 1, 1, 1, 1, c8_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Conv2d (&net, l->output_dim, 128, 1, 1, 1, 1, 0, 0, c9_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Conv2d (&net, l->output_dim, 256, 3, 3, 1, 1, 1, 1, c10_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Pooling (&net, l->output_dim, 2, 2, 2, 2, tkDNN::POOLING_MAX);
l = new tkDNN::Conv2d (&net, l->output_dim, 512, 3, 3, 1, 1, 1, 1, c12_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Conv2d (&net, l->output_dim, 256, 1, 1, 1, 1, 0, 0, c13_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Conv2d (&net, l->output_dim, 512, 3, 3, 1, 1, 1, 1, c14_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Conv2d (&net, l->output_dim, 256, 1, 1, 1, 1, 0, 0, c15_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Conv2d (&net, l->output_dim, 512, 3, 3, 1, 1, 1, 1, c16_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY); //29
l = new tkDNN::Pooling (&net, l->output_dim, 2, 2, 2, 2, tkDNN::POOLING_MAX);
l = new tkDNN::Conv2d (&net, l->output_dim, 1024, 3, 3, 1, 1, 1, 1, c18_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Conv2d (&net, l->output_dim, 512, 1, 1, 1, 1, 0, 0, c19_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Conv2d (&net, l->output_dim, 1024, 3, 3, 1, 1, 1, 1, c20_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Conv2d (&net, l->output_dim, 512, 1, 1, 1, 1, 0, 0, c21_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Conv2d (&net, l->output_dim, 1024, 3, 3, 1, 1, 1, 1, c22_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Conv2d (&net, l->output_dim, 1024, 3, 3, 1, 1, 1, 1, c23_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Conv2d (&net, l->output_dim, 1024, 3, 3, 1, 1, 1, 1, c24_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY); //44
int rlayers[1] = {29};
l = new tkDNN::Route (&net, rlayers, 1);
l = new tkDNN::Conv2d (&net, l->output_dim, 64, 1, 1, 1, 1, 0, 0, c26_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Reorg (&net, l->output_dim, 2); //48
int rlayers2[2] = {48,44};
l = new tkDNN::Route (&net, rlayers2, 2);
l = new tkDNN::Conv2d (&net, l->output_dim, 1024, 3, 3, 1, 1, 1, 1, c29_bin, true);
l = new tkDNN::Activation (&net, l->output_dim, tkDNN::ACTIVATION_LEAKY);
l = new tkDNN::Conv2d (&net, l->output_dim, 425, 1, 1, 1, 1, 0, 0, c30_bin, false);
l = new tkDNN::Region (&net, l->output_dim, 80, 4, 5, 0.6f);
// Load input
value_type *data;
value_type *input_h;
readBinaryFile(input_bin, dim.tot(), &input_h, &data);
dim.print(); //print initial dimension
TIMER_START
// Inference
data = net.infer(dim, data);
TIMER_STOP
dim.print();
// Print real test
std::cout<<"\n==== CHECK RESULT ====\n";
value_type *out;
value_type *out_h;
readBinaryFile(output_bin, dim.tot(), &out_h, &out);
int diff = checkResult(dim.tot(), data, out);
printf("Output diffs: %d\n", diff);
return 0;
}