2 input shortcut

This commit is contained in:
Francesco Gatti
2018-12-21 16:16:38 +01:00
parent 64626bf547
commit 53b429551d
2 changed files with 9 additions and 6 deletions
+5 -3
View File
@@ -328,9 +328,11 @@ ILayer* NetworkRT::convert_layer(ITensor *input, Shortcut *l) {
//std::cout<<"convert Shortcut\n";
//std::cout<<"New plugin Shortcut\n";
ITensor *tens = tensors[l->backLayer];
IPlugin *plugin = new ShortcutRT(tens);
IPluginLayer *lRT = networkRT->addPlugin(&input, 1, *plugin);
ITensor *back_tens = tensors[l->backLayer];
IPlugin *plugin = new ShortcutRT();
ITensor *inputs[2] = { input, back_tens };
IPluginLayer *lRT = networkRT->addPlugin(inputs, 2, *plugin);
checkNULL(lRT);
return lRT;
}
+4 -3
View File
@@ -4,8 +4,7 @@
class ShortcutRT : public IPlugin {
public:
ShortcutRT(ITensor *tens) {
this->back_layer = tens;
ShortcutRT() {
}
~ShortcutRT(){
@@ -41,9 +40,12 @@ public:
virtual int enqueue(int batchSize, const void*const * inputs, void** outputs, void* workspace, cudaStream_t stream) override {
dnnType *srcData = (dnnType*)reinterpret_cast<const dnnType*>(inputs[0]);
dnnType *srcDataBack = (dnnType*)reinterpret_cast<const dnnType*>(inputs[1]);
dnnType *dstData = reinterpret_cast<dnnType*>(outputs[0]);
checkCuda( cudaMemcpyAsync(dstData, srcData, batchSize*c*h*w*sizeof(dnnType), cudaMemcpyDeviceToDevice, stream));
shortcutForward(srcDataBack, dstData, batchSize, c, h, w, 1, batchSize, c, h, w, 1);
return 0;
}
@@ -60,5 +62,4 @@ public:
}
int c, h, w;
ITensor *back_layer;
};