diff --git a/include/Layer.h b/include/Layer.h index 3898471..d4d0378 100644 --- a/include/Layer.h +++ b/include/Layer.h @@ -17,7 +17,8 @@ enum layerType_t { LAYER_SOFTMAX, LAYER_ROUTE, LAYER_REORG, - LAYER_REGION + LAYER_SHORTCUT, + LAYER_REGION, }; /** @@ -50,6 +51,7 @@ public: case LAYER_SOFTMAX: return "Softmax"; case LAYER_ROUTE: return "Route"; case LAYER_REORG: return "Reorg"; + case LAYER_SHORTCUT: return "Shortcut"; case LAYER_REGION: return "Region"; default: return "unknown"; } @@ -282,6 +284,23 @@ public: int stride; }; +/** + Shortcut layer + sum with stride another layer +*/ +class Shortcut : public Layer { + +public: + Shortcut(Network *net, Layer *backLayer, int layers_n); + virtual ~Shortcut(); + virtual layerType_t getLayerType() { return LAYER_SHORTCUT; }; + + virtual dnnType* infer(dataDim_t &dim, dnnType* srcData); + +public: + Layer *backLayer; +}; + struct box { int cl; diff --git a/src/Shortcut.cpp b/src/Shortcut.cpp new file mode 100644 index 0000000..3c40a8e --- /dev/null +++ b/src/Shortcut.cpp @@ -0,0 +1,30 @@ +#include + +#include "Layer.h" +#include "kernels.h" + +namespace tk { namespace dnn { + +Shortcut::Shortcut(Network *net, Layer *backLayer, int layers_n) : Layer(net) { + + this->backLayer = backLayer; + checkCuda( cudaMalloc(&dstData, output_dim.tot()*sizeof(dnnType)) ); +} + +Shortcut::~Shortcut() { + + checkCuda( cudaFree(dstData) ); +} + +dnnType* Shortcut::infer(dataDim_t &dim, dnnType* srcData) { + + + + + //update data dimensions + dim = output_dim; + + return dstData; +} + +}} \ No newline at end of file