diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a30260..4e5e4e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ add_library(tkDNN SHARED src/Layer.cpp src/LayerWgs.cpp src/Route.cpp src/Reorg.cpp src/Region.cpp src/Network.cpp src/utils.cpp) target_link_libraries(tkDNN kernels ${CUDA_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES} -lcudnn -lnvinfer) -add_executable(test_simple tests/test/test_simple.cpp) +add_executable(test_simple tests/simple/test_simple.cpp) target_link_libraries(test_simple tkDNN) add_executable(test_mnist tests/mnist/test_mnist.cpp) diff --git a/include/Layer.h b/include/Layer.h index dfa6950..8a15711 100644 --- a/include/Layer.h +++ b/include/Layer.h @@ -7,40 +7,13 @@ namespace tkDNN { -/** - Data rapresentation beetween layers - n = batch size - c = channels - h = heigth (lines) - w = width (rows) - l = lenght (3rd dimension) -*/ -struct dataDim_t { - - int n, c, h, w, l; - - dataDim_t() : n(1), c(1), h(1), w(1), l(1) {}; - - dataDim_t(int _n, int _c, int _h, int _w, int _l = 1) : - n(_n), c(_c), h(_h), w(_w), l(_l) {}; - - void print() { - std::cout<<"Data dim: "<act_mode = act_mode; checkCuda( cudaMalloc(&dstData, input_dim.tot()*sizeof(value_type)) ); diff --git a/src/Conv2d.cpp b/src/Conv2d.cpp index 46360d6..1821194 100644 --- a/src/Conv2d.cpp +++ b/src/Conv2d.cpp @@ -4,12 +4,11 @@ namespace tkDNN { -Conv2d::Conv2d( Network *net, dataDim_t in_dim, int out_ch, - int kernelH, int kernelW, int strideH, int strideW, - int paddingH, int paddingW, +Conv2d::Conv2d( Network *net, int out_ch, int kernelH, int kernelW, + int strideH, int strideW, int paddingH, int paddingW, const char* fname_weights, bool batchnorm) : - LayerWgs(net, in_dim, in_dim.c, out_ch, kernelH, kernelW, 1, + LayerWgs(net, net->getOutputDim().c, out_ch, kernelH, kernelW, 1, fname_weights, batchnorm) { this->kernelH = kernelH; diff --git a/src/Dense.cpp b/src/Dense.cpp index 4f8cc05..fa49a28 100644 --- a/src/Dense.cpp +++ b/src/Dense.cpp @@ -4,9 +4,8 @@ namespace tkDNN { -Dense::Dense(Network *net, dataDim_t in_dim, - int out_ch, const char* fname_weights) : - LayerWgs(net, in_dim, in_dim.tot(), out_ch, 1, 1, 1, fname_weights) { +Dense::Dense(Network *net, int out_ch, const char* fname_weights) : + LayerWgs(net, net->getOutputDim().tot(), out_ch, 1, 1, 1, fname_weights) { output_dim.n = 1; output_dim.c = out_ch; diff --git a/src/Flatten.cpp b/src/Flatten.cpp index 713c156..7751c8d 100644 --- a/src/Flatten.cpp +++ b/src/Flatten.cpp @@ -5,8 +5,7 @@ namespace tkDNN { -Flatten::Flatten(Network *net, dataDim_t input_dim) : - Layer(net, input_dim) { +Flatten::Flatten(Network *net) : Layer(net) { checkCuda( cudaMalloc(&dstData, input_dim.tot()*sizeof(value_type)) ); diff --git a/src/Layer.cpp b/src/Layer.cpp index 7e689ee..4f585f7 100644 --- a/src/Layer.cpp +++ b/src/Layer.cpp @@ -4,11 +4,11 @@ namespace tkDNN { -Layer::Layer(Network *net, dataDim_t in_dim) { +Layer::Layer(Network *net) { this->net = net; - this->input_dim = in_dim; - this->output_dim = in_dim; + this->input_dim = net->getOutputDim(); + this->output_dim = input_dim; checkCUDNN( cudnnCreateTensorDescriptor(&srcTensorDesc) ); checkCUDNN( cudnnCreateTensorDescriptor(&dstTensorDesc) ); diff --git a/src/LayerWgs.cpp b/src/LayerWgs.cpp index 58d40a7..1e0086c 100644 --- a/src/LayerWgs.cpp +++ b/src/LayerWgs.cpp @@ -4,9 +4,9 @@ namespace tkDNN { -LayerWgs::LayerWgs(Network *net, dataDim_t in_dim, - int inputs, int outputs, int kh, int kw, int kl, - const char* fname_weights, bool batchnorm) : Layer(net, in_dim) { +LayerWgs::LayerWgs(Network *net, int inputs, int outputs, + int kh, int kw, int kl, + const char* fname_weights, bool batchnorm) : Layer(net) { this->inputs = inputs; this->outputs = outputs; diff --git a/src/MulAdd.cpp b/src/MulAdd.cpp index dd7cfd2..9d9745b 100644 --- a/src/MulAdd.cpp +++ b/src/MulAdd.cpp @@ -5,8 +5,7 @@ namespace tkDNN { -MulAdd::MulAdd(Network *net, dataDim_t input_dim, value_type mul, value_type add) : - Layer(net, input_dim) { +MulAdd::MulAdd(Network *net, value_type mul, value_type add) : Layer(net) { this->mul = mul; this->add = add; diff --git a/src/Network.cpp b/src/Network.cpp index c0c101d..a901fcd 100644 --- a/src/Network.cpp +++ b/src/Network.cpp @@ -7,7 +7,8 @@ namespace tkDNN { -Network::Network() { +Network::Network(dataDim_t input_dim) { + this->input_dim = input_dim; float tk_ver = float(tkDNN::getVersion())/1000; float cu_ver = float(cudnnGetVersion())/1000; @@ -47,4 +48,12 @@ bool Network::addLayer(Layer *l) { return true; } +dataDim_t Network::getOutputDim() { + + if(num_layers == 0) + return input_dim; + else + return layers[num_layers-1]->output_dim; +} + } \ No newline at end of file diff --git a/src/Pooling.cpp b/src/Pooling.cpp index 2d964fc..fa442c6 100644 --- a/src/Pooling.cpp +++ b/src/Pooling.cpp @@ -5,9 +5,9 @@ namespace tkDNN { -Pooling::Pooling( Network *net, dataDim_t input_dim, - int winH, int winW, int strideH, int strideW, tkdnnPoolingMode_t pool_mode) : - Layer(net, input_dim) { +Pooling::Pooling( Network *net, int winH, int winW, + int strideH, int strideW, tkdnnPoolingMode_t pool_mode) : + Layer(net) { if(winH != strideH || winW != strideW) diff --git a/src/Region.cpp b/src/Region.cpp index 0a032cf..39c19bb 100644 --- a/src/Region.cpp +++ b/src/Region.cpp @@ -5,9 +5,8 @@ namespace tkDNN { -Region::Region(Network *net, dataDim_t input_dim, - int classes, int coords, int num, float thresh) : - Layer(net, input_dim) { +Region::Region(Network *net, int classes, int coords, int num, float thresh) : + Layer(net) { this->classes = classes; this->coords = coords; diff --git a/src/Reorg.cpp b/src/Reorg.cpp index 7c64f33..1650e6c 100644 --- a/src/Reorg.cpp +++ b/src/Reorg.cpp @@ -5,8 +5,7 @@ namespace tkDNN { -Reorg::Reorg(Network *net, dataDim_t input_dim, int stride) : - Layer(net, input_dim) { +Reorg::Reorg(Network *net, int stride) : Layer(net) { this->stride = stride; diff --git a/src/Route.cpp b/src/Route.cpp index 643cdea..99d9923 100644 --- a/src/Route.cpp +++ b/src/Route.cpp @@ -5,17 +5,11 @@ namespace tkDNN { -Route::Route(Network *net, int *layers_id, int layers_n) : - Layer(net, dataDim_t()) { +Route::Route(Network *net, Layer **layers, int layers_n) : Layer(net) { + this->layers = layers; this->layers_n = layers_n; - //get layers - layers = new Layer*[layers_n]; - for(int i=0; ilayers[layers_id[i]]; - - //get dims output_dim.l = 1; output_dim.c = 0; diff --git a/src/Softmax.cpp b/src/Softmax.cpp index bd59ea7..f3b85fe 100644 --- a/src/Softmax.cpp +++ b/src/Softmax.cpp @@ -5,8 +5,7 @@ namespace tkDNN { -Softmax::Softmax(Network *net, dataDim_t input_dim) : - Layer(net, input_dim) { +Softmax::Softmax(Network *net) : Layer(net) { checkCuda( cudaMalloc(&dstData, input_dim.tot()*sizeof(value_type)) ); diff --git a/tests/build_models.sh b/tests/build_models.sh old mode 100755 new mode 100644 diff --git a/tests/mnist/test_mnist.cpp b/tests/mnist/test_mnist.cpp index 0542649..ba9e216 100644 --- a/tests/mnist/test_mnist.cpp +++ b/tests/mnist/test_mnist.cpp @@ -11,17 +11,16 @@ const char *output_bin = "../tests/mnist/output.bin"; int main() { // Network layout - 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, 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, 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); - l = new tkDNN::Dense (&net, l->output_dim, 10, d3_bin); - l = new tkDNN::Softmax (&net, l->output_dim); + tkDNN::Network net(dim); + tkDNN::Conv2d l0(&net, 20, 5, 5, 1, 1, 0, 0, c0_bin); + tkDNN::Pooling l1(&net, 2, 2, 2, 2, tkDNN::POOLING_MAX); + tkDNN::Conv2d l2(&net, 50, 5, 5, 1, 1, 0, 0, c1_bin); + tkDNN::Pooling l3(&net, 2, 2, 2, 2, tkDNN::POOLING_MAX); + tkDNN::Dense l4(&net, 500, d2_bin); + tkDNN::Activation l5(&net, CUDNN_ACTIVATION_RELU); + tkDNN::Dense l6(&net, 10, d3_bin); + tkDNN::Softmax l7(&net); // Load input value_type *data; diff --git a/tests/mnist/test_mnistRT.cpp b/tests/mnist/test_mnistRT.cpp index 2a89797..74a2d2f 100644 --- a/tests/mnist/test_mnistRT.cpp +++ b/tests/mnist/test_mnistRT.cpp @@ -27,17 +27,16 @@ int main() { std::cout<<"\n==== CUDNN ====\n"; // Network layout - 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, 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, 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); - l = new tkDNN::Dense (&net, l->output_dim, 10, d3_bin); - l = new tkDNN::Softmax (&net, l->output_dim); + tkDNN::Network net(dim); + tkDNN::Conv2d l0(&net, 20, 5, 5, 1, 1, 0, 0, c0_bin); + tkDNN::Pooling l1(&net, 2, 2, 2, 2, tkDNN::POOLING_MAX); + tkDNN::Conv2d l2(&net, 50, 5, 5, 1, 1, 0, 0, c1_bin); + tkDNN::Pooling l3(&net, 2, 2, 2, 2, tkDNN::POOLING_MAX); + tkDNN::Dense l4(&net, 500, d2_bin); + tkDNN::Activation l5(&net, CUDNN_ACTIVATION_RELU); + tkDNN::Dense l6(&net, 10, d3_bin); + tkDNN::Softmax l7(&net); // Load input value_type *data; @@ -72,7 +71,7 @@ int main() { auto input = network->addInput("data", dt, DimsCHW{ 1, 28, 28}); assert(input != nullptr); - tkDNN::Conv2d *c0 = (tkDNN::Conv2d*) (net.layers[0]); + tkDNN::Conv2d *c0 = &l0; Weights w { dt, c0->data_h, c0->inputs*c0->outputs*c0->kernelH*c0->kernelW}; Weights b { dt, c0->bias_h, c0->outputs}; // Add a convolution layer with 20 outputs and a 5x5 filter. @@ -85,7 +84,7 @@ int main() { assert(pool1 != nullptr); pool1->setStride(DimsHW{2, 2}); - tkDNN::Conv2d *c1 = (tkDNN::Conv2d*) (net.layers[2]); + tkDNN::Conv2d *c1 = &l2; Weights w1 { dt, c1->data_h, c1->inputs*c1->outputs*c1->kernelH*c1->kernelW}; Weights b1 { dt, c1->bias_h, c1->outputs}; // Add a second convolution layer with 50 outputs and a 5x5 filter. @@ -98,7 +97,7 @@ int main() { assert(pool2 != nullptr); pool2->setStride(DimsHW{2, 2}); - tkDNN::Dense *d2 = (tkDNN::Dense*) (net.layers[4]); + tkDNN::Dense *d2 = &l4; Weights w2 { dt, d2->data_h, d2->inputs*d2->outputs}; Weights b2 { dt, d2->bias_h, d2->outputs}; // Add a fully connected layer with 500 outputs. @@ -109,7 +108,7 @@ int main() { auto relu1 = network->addActivation(*ip1->getOutput(0), ActivationType::kRELU); assert(relu1 != nullptr); - tkDNN::Conv2d *d3 = (tkDNN::Conv2d*) (net.layers[6]); + tkDNN::Dense *d3 = &l6; Weights w3 { dt, d3->data_h, d3->inputs*d3->outputs}; Weights b3 { dt, d3->bias_h, d3->outputs}; // Add a second fully connected layer with 20 outputs. diff --git a/tests/test/test_model.py b/tests/simple/test_model.py similarity index 100% rename from tests/test/test_model.py rename to tests/simple/test_model.py diff --git a/tests/test/test_simple.cpp b/tests/simple/test_simple.cpp similarity index 65% rename from tests/test/test_simple.cpp rename to tests/simple/test_simple.cpp index 73f049e..56d24c5 100644 --- a/tests/test/test_simple.cpp +++ b/tests/simple/test_simple.cpp @@ -10,16 +10,15 @@ const char *output_bin = "../tests/test/output.bin"; int main() { // Network layout - 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, 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, 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); - l = new tkDNN::Activation (&net, l->output_dim, CUDNN_ACTIVATION_RELU); + tkDNN::Network net(dim); + tkDNN::Conv2d l0(&net, 2, 4, 4, 2, 2, 0, 0, c0_bin); + tkDNN::Activation l1(&net, CUDNN_ACTIVATION_RELU); + tkDNN::Conv2d l2(&net, 4, 2, 2, 1, 1, 0, 0, c1_bin); + tkDNN::Activation l3(&net, CUDNN_ACTIVATION_RELU); + tkDNN::Flatten l4(&net); + tkDNN::Dense l5(&net, 4, d2_bin); + tkDNN::Activation l6(&net, CUDNN_ACTIVATION_RELU); // Load input value_type *data; @@ -30,11 +29,8 @@ int main() { dim.print(); //print initial dimension TIMER_START - // Inference data = net.infer(dim, data); dim.print(); - - TIMER_STOP // Print result diff --git a/tests/yolo/yolo.cpp b/tests/yolo/yolo.cpp index 8e4c23f..019b0f9 100644 --- a/tests/yolo/yolo.cpp +++ b/tests/yolo/yolo.cpp @@ -30,74 +30,74 @@ 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); + tkDNN::Network net(dim); - 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); + tkDNN::Conv2d c0 (&net, 32, 3, 3, 1, 1, 1, 1, c0_bin, true); + tkDNN::Activation a0 (&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Pooling p1 (&net, 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); + tkDNN::Conv2d c2 (&net, 64, 3, 3, 1, 1, 1, 1, c2_bin, true); + tkDNN::Activation a2 (&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Pooling p3 (&net, 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); + tkDNN::Conv2d c4 (&net, 128, 3, 3, 1, 1, 1, 1, c4_bin, true); + tkDNN::Activation a4 (&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Conv2d c5 (&net, 64, 1, 1, 1, 1, 0, 0, c5_bin, true); + tkDNN::Activation a5 (&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Conv2d c6 (&net, 128, 3, 3, 1, 1, 1, 1, c6_bin, true); + tkDNN::Activation a6 (&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Pooling p7 (&net, 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); + tkDNN::Conv2d c8 (&net, 256, 3, 3, 1, 1, 1, 1, c8_bin, true); + tkDNN::Activation a8 (&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Conv2d c9 (&net, 128, 1, 1, 1, 1, 0, 0, c9_bin, true); + tkDNN::Activation a9 (&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Conv2d c10(&net, 256, 3, 3, 1, 1, 1, 1, c10_bin, true); + tkDNN::Activation a10(&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Pooling p11(&net, 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 + tkDNN::Conv2d c12(&net, 512, 3, 3, 1, 1, 1, 1, c12_bin, true); + tkDNN::Activation a12(&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Conv2d c13(&net, 256, 1, 1, 1, 1, 0, 0, c13_bin, true); + tkDNN::Activation a13(&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Conv2d c14(&net, 512, 3, 3, 1, 1, 1, 1, c14_bin, true); + tkDNN::Activation a14(&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Conv2d c15(&net, 256, 1, 1, 1, 1, 0, 0, c15_bin, true); + tkDNN::Activation a15(&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Conv2d c16(&net, 512, 3, 3, 1, 1, 1, 1, c16_bin, true); + tkDNN::Activation a16(&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Pooling p17(&net, 2, 2, 2, 2, tkDNN::POOLING_MAX); - 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 + tkDNN::Conv2d c18(&net, 1024, 3, 3, 1, 1, 1, 1, c18_bin, true); + tkDNN::Activation a18(&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Conv2d c19(&net, 512, 1, 1, 1, 1, 0, 0, c19_bin, true); + tkDNN::Activation a19(&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Conv2d c20(&net, 1024, 3, 3, 1, 1, 1, 1, c20_bin, true); + tkDNN::Activation a20(&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Conv2d c21(&net, 512, 1, 1, 1, 1, 0, 0, c21_bin, true); + tkDNN::Activation a21(&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Conv2d c22(&net, 1024, 3, 3, 1, 1, 1, 1, c22_bin, true); + tkDNN::Activation a22(&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Conv2d c23(&net, 1024, 3, 3, 1, 1, 1, 1, c23_bin, true); + tkDNN::Activation a23(&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Conv2d c24(&net, 1024, 3, 3, 1, 1, 1, 1, c24_bin, true); + tkDNN::Activation a24(&net, tkDNN::ACTIVATION_LEAKY); - int rlayers2[2] = {48,44}; - l = new tkDNN::Route (&net, rlayers2, 2); + tkDNN::Layer *m25_layers[1] = { &a16 }; + tkDNN::Route m25(&net, m25_layers, 1); + tkDNN::Conv2d c26(&net, 64, 1, 1, 1, 1, 0, 0, c26_bin, true); + tkDNN::Activation a26(&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Reorg r27(&net, 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); + tkDNN::Layer *m28_layers[2] = { &r27, &a24 }; + tkDNN::Route m28(&net, m28_layers, 2); - l = new tkDNN::Region (&net, l->output_dim, 80, 4, 5, 0.6f); + tkDNN::Conv2d c29(&net, 1024, 3, 3, 1, 1, 1, 1, c29_bin, true); + tkDNN::Activation a29(&net, tkDNN::ACTIVATION_LEAKY); + tkDNN::Conv2d c30(&net, 425, 1, 1, 1, 1, 0, 0, c30_bin, false); + + tkDNN::Region g31(&net, 80, 4, 5, 0.6f); // Load input value_type *data;