shortcut template

This commit is contained in:
Francesco Gatti
2018-12-19 22:36:46 +01:00
parent bc0ea65766
commit 5f25e0b5f6
2 changed files with 50 additions and 1 deletions
+20 -1
View File
@@ -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;
+30
View File
@@ -0,0 +1,30 @@
#include <iostream>
#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;
}
}}