upsample template

This commit is contained in:
Francesco Gatti
2018-12-19 22:45:43 +01:00
parent 5f25e0b5f6
commit ed02930464
2 changed files with 50 additions and 0 deletions
+17
View File
@@ -18,6 +18,7 @@ enum layerType_t {
LAYER_ROUTE,
LAYER_REORG,
LAYER_SHORTCUT,
LAYER_UPSAMPLE,
LAYER_REGION,
};
@@ -52,6 +53,7 @@ public:
case LAYER_ROUTE: return "Route";
case LAYER_REORG: return "Reorg";
case LAYER_SHORTCUT: return "Shortcut";
case LAYER_UPSAMPLE: return "Upsample";
case LAYER_REGION: return "Region";
default: return "unknown";
}
@@ -301,6 +303,21 @@ public:
Layer *backLayer;
};
/**
Upsample layer
Mantain same dimension but change C*H*W distribution
*/
class Upsample : public Layer {
public:
Upsample(Network *net, int stride);
virtual ~Upsample();
virtual layerType_t getLayerType() { return LAYER_UPSAMPLE; };
virtual dnnType* infer(dataDim_t &dim, dnnType* srcData);
int stride;
};
struct box {
int cl;
+33
View File
@@ -0,0 +1,33 @@
#include <iostream>
#include "Layer.h"
#include "kernels.h"
namespace tk { namespace dnn {
Upsample::Upsample(Network *net, int stride) : Layer(net) {
this->stride = stride;
output_dim.n = input_dim.n;
output_dim.c = input_dim.c*stride*stride;
output_dim.h = input_dim.h/stride;
output_dim.w = input_dim.w/stride;
output_dim.l = input_dim.l;
checkCuda( cudaMalloc(&dstData, input_dim.tot()*sizeof(dnnType)) );
}
Upsample::~Upsample() {
checkCuda( cudaFree(dstData) );
}
dnnType* Upsample::infer(dataDim_t &dim, dnnType* srcData) {
dim = output_dim;
return dstData;
}
}}