upsample template
This commit is contained in:
@@ -18,6 +18,7 @@ enum layerType_t {
|
|||||||
LAYER_ROUTE,
|
LAYER_ROUTE,
|
||||||
LAYER_REORG,
|
LAYER_REORG,
|
||||||
LAYER_SHORTCUT,
|
LAYER_SHORTCUT,
|
||||||
|
LAYER_UPSAMPLE,
|
||||||
LAYER_REGION,
|
LAYER_REGION,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -52,6 +53,7 @@ public:
|
|||||||
case LAYER_ROUTE: return "Route";
|
case LAYER_ROUTE: return "Route";
|
||||||
case LAYER_REORG: return "Reorg";
|
case LAYER_REORG: return "Reorg";
|
||||||
case LAYER_SHORTCUT: return "Shortcut";
|
case LAYER_SHORTCUT: return "Shortcut";
|
||||||
|
case LAYER_UPSAMPLE: return "Upsample";
|
||||||
case LAYER_REGION: return "Region";
|
case LAYER_REGION: return "Region";
|
||||||
default: return "unknown";
|
default: return "unknown";
|
||||||
}
|
}
|
||||||
@@ -301,6 +303,21 @@ public:
|
|||||||
Layer *backLayer;
|
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 {
|
struct box {
|
||||||
int cl;
|
int cl;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}}
|
||||||
Reference in New Issue
Block a user