Added TensorRT8 support #270

Closed
TheExDeus wants to merge 6 commits from feature/tensorrt8_support into master
Showing only changes of commit 18303c06c5 - Show all commits
+20 -13
View File
@@ -419,28 +419,35 @@ ILayer* NetworkRT::convert_layer(ITensor *input, Activation *l) {
IActivationLayer *lRT = networkRT->addActivation(*input, ActivationType::kRELU); IActivationLayer *lRT = networkRT->addActivation(*input, ActivationType::kRELU);
checkNULL(lRT); checkNULL(lRT);
return lRT; return lRT;
} else if(l->act_mode == CUDNN_ACTIVATION_SIGMOID) { } else if(l->act_mode == CUDNN_ACTIVATION_SIGMOID || l->act_mode == ACTIVATION_LOGISTIC) {
IActivationLayer *lRT = networkRT->addActivation(*input, ActivationType::kSIGMOID); IActivationLayer *lRT = networkRT->addActivation(*input, ActivationType::kSIGMOID);
checkNULL(lRT); checkNULL(lRT);
return lRT; return lRT;
} }
else if(l->act_mode == CUDNN_ACTIVATION_CLIPPED_RELU) { else if(l->act_mode == CUDNN_ACTIVATION_CLIPPED_RELU) {
auto *plugin = new ActivationReLUCeiling(l->ceiling); IActivationLayer *lRT = networkRT->addActivation(*input, ActivationType::kCLIP);
auto *lRT = networkRT->addPluginV2(&input, 1, *plugin); lRT->setAlpha(0);
lRT->setBeta(l->ceiling);
checkNULL(lRT); checkNULL(lRT);
return lRT; return lRT;
} }
else if(l->act_mode == ACTIVATION_MISH) { else if(l->act_mode == ACTIVATION_MISH) {
auto *plugin = new ActivationMishRT(); // Uncomment this to see if you have better performance
auto *lRT = networkRT->addPluginV2(&input, 1, *plugin); // For older TensorRT or for FP32 this might be better
checkNULL(lRT); //auto *plugin = new ActivationMishRT();
return lRT; //auto *lRT = networkRT->addPluginV2(&input, 1, *plugin);
}
else if(l->act_mode == ACTIVATION_LOGISTIC) { // Assemble MISH using 3 layers that are going to be merged by TensorRT
auto *plugin = new ActivationLogisticRT(); IActivationLayer *lRT1 = networkRT->addActivation(*input, ActivationType::kSOFTPLUS);
auto *lRT = networkRT->addPluginV2(&input, 1, *plugin); lRT1->setAlpha(1);
checkNULL(lRT); lRT1->setBeta(1);
return lRT;
IActivationLayer *lRT2 = networkRT->addActivation(*lRT1->getOutput(0), ActivationType::kTANH);
IElementWiseLayer *lRT3 = networkRT->addElementWise(*input, *lRT2->getOutput(0), ElementWiseOperation::kPROD);
checkNULL(lRT3);
return lRT3;
} }
else { else {
FatalError("this Activation mode is not yet implemented"); FatalError("this Activation mode is not yet implemented");