From 0a9957ba187a57639cbf68c264802d3029349e94 Mon Sep 17 00:00:00 2001 From: Francesco Gatti Date: Tue, 8 Aug 2017 14:59:25 +0200 Subject: [PATCH] network print --- include/Layer.h | 17 ++++++++++++++++ include/Network.h | 1 + include/utils.h | 1 + src/Network.cpp | 38 ++++++++++++++++++++++++++++++++++- src/utils.cpp | 12 +++++++++++ tests/yolo-tiny/yolo-tiny.cpp | 2 +- 6 files changed, 69 insertions(+), 2 deletions(-) diff --git a/include/Layer.h b/include/Layer.h index 4b5c6ae..efc69f9 100644 --- a/include/Layer.h +++ b/include/Layer.h @@ -38,6 +38,23 @@ public: dataDim_t input_dim, output_dim; value_type *dstData; //where results will be putted + std::string getLayerName() { + layerType_t type = getLayerType(); + switch(type) { + case LAYER_DENSE: return "Dense"; + case LAYER_CONV2D: return "Conv2d"; + case LAYER_ACTIVATION: return "Activation"; + case LAYER_FLATTEN: return "Flatten"; + case LAYER_MULADD: return "MulAdd"; + case LAYER_POOLING: return "Pooling"; + case LAYER_SOFTMAX: return "Softmax"; + case LAYER_ROUTE: return "Route"; + case LAYER_REORG: return "Reorg"; + case LAYER_REGION: return "Region"; + default: return "unknown"; + } + } + protected: Network *net; cudnnTensorDescriptor_t srcTensorDesc, dstTensorDesc; diff --git a/include/Network.h b/include/Network.h index 814853b..e0decdb 100644 --- a/include/Network.h +++ b/include/Network.h @@ -46,6 +46,7 @@ public: value_type* infer(dataDim_t &dim, value_type* data); bool addLayer(Layer *l); + void print(); cudnnDataType_t dataType; cudnnTensorFormat_t tensorFormat; diff --git a/include/utils.h b/include/utils.h index c0ea8a8..2eb1c10 100644 --- a/include/utils.h +++ b/include/utils.h @@ -87,6 +87,7 @@ } \ } +void printCenteredTitle(const char *title, char fill, int dim); void readBinaryFile(const char* fname, int size, value_type** data_h, value_type** data_d, int seek = 0); int checkResult(int size, value_type *data_d, value_type *correct_d, bool device = true); void printDeviceVector(int size, value_type* vec_d, bool device = true); diff --git a/src/Network.cpp b/src/Network.cpp index 096cb09..53de17c 100644 --- a/src/Network.cpp +++ b/src/Network.cpp @@ -1,4 +1,5 @@ #include +#include #include "tkdnn.h" #include "Network.h" @@ -34,7 +35,6 @@ value_type* Network::infer(dataDim_t &dim, value_type* data) { //do infer for every layer for(int i=0; iinfer(dim, data); - //dim.print(); } checkCuda(cudaDeviceSynchronize()); return data; @@ -56,4 +56,40 @@ dataDim_t Network::getOutputDim() { return layers[num_layers-1]->output_dim; } +void Network::print() { + + std::cout<<"\n"; + printCenteredTitle(" NETWORK MODEL ", '=', 60); + std::cout.width(3); std::cout<input_dim; + dataDim_t out = layers[i]->output_dim; + + std::cout.width(3); std::cout<getLayerName(); + std::cout.width(4); std::cout< "; + std::cout.width(4); std::cout<