LEAKY plugin
This commit is contained in:
+10
-2
@@ -4,6 +4,7 @@
|
||||
#include "NetworkRT.h"
|
||||
|
||||
using namespace nvinfer1;
|
||||
#include "pluginsRT/ActivationLeakyRT.cpp"
|
||||
|
||||
// Logger for info/warning/errors
|
||||
class Logger : public ILogger
|
||||
@@ -183,14 +184,21 @@ ITensor* NetworkRT::convert_layer(ITensor *input, Pooling *l) {
|
||||
ITensor* NetworkRT::convert_layer(ITensor *input, Activation *l) {
|
||||
std::cout<<"convert Activation\n";
|
||||
|
||||
if(l->act_mode == ACTIVATION_LEAKY) {
|
||||
std::cout<<"New plugin LEAKY\n";
|
||||
IPlugin *plugin = new ActivationLeakyRT();
|
||||
IPluginLayer *lRT = networkRT->addPlugin(&input, 1, *plugin);
|
||||
checkNULL(lRT);
|
||||
return lRT->getOutput(0);
|
||||
}
|
||||
|
||||
IActivationLayer *lRT = networkRT->addActivation(*input, ActivationType::kRELU);
|
||||
checkNULL(lRT);
|
||||
|
||||
return lRT->getOutput(0);
|
||||
}
|
||||
|
||||
ITensor* NetworkRT::convert_layer(ITensor *input, Softmax *l) {
|
||||
std::cout<<"convert Activation\n";
|
||||
std::cout<<"convert softmax\n";
|
||||
|
||||
ISoftMaxLayer *lRT = networkRT->addSoftMax(*input);
|
||||
checkNULL(lRT);
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
#include<cassert>
|
||||
#include "kernels.h"
|
||||
|
||||
class ActivationLeakyRT : public IPlugin {
|
||||
|
||||
public:
|
||||
ActivationLeakyRT() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
~ActivationLeakyRT(){
|
||||
|
||||
}
|
||||
|
||||
int getNbOutputs() const override {
|
||||
return 1;
|
||||
}
|
||||
|
||||
Dims getOutputDimensions(int index, const Dims* inputs, int nbInputDims) override {
|
||||
return inputs[0];
|
||||
}
|
||||
|
||||
void configure(const Dims* inputDims, int nbInputs, const Dims* outputDims, int nbOutputs, int maxBatchSize) override {
|
||||
size = 1;
|
||||
for(int i=0; i<outputDims[0].nbDims; i++)
|
||||
size *= outputDims[0].d[i];
|
||||
}
|
||||
|
||||
int initialize() override {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void terminate() override {
|
||||
}
|
||||
|
||||
virtual size_t getWorkspaceSize(int maxBatchSize) const override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int enqueue(int batchSize, const void*const * inputs, void** outputs, void* workspace, cudaStream_t stream) override {
|
||||
|
||||
activationLEAKYForward((value_type*)reinterpret_cast<const value_type*>(inputs[0]),
|
||||
reinterpret_cast<value_type*>(outputs[0]), size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virtual size_t getSerializationSize() override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual void serialize(void* buffer) override {
|
||||
}
|
||||
|
||||
int size;
|
||||
};
|
||||
Reference in New Issue
Block a user