shortcut template
This commit is contained in:
+20
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}}
|
||||
Reference in New Issue
Block a user