tkDNN works with trt8!!,need to test int8 and mobilenet,dla_cnet (fps seems to be a bit low 350 on trt8 compared to 396 on trt7)

This commit is contained in:
perseusdg
2021-09-07 22:00:28 +05:30
parent 9fa116ce4a
commit 03473743c4
30 changed files with 43 additions and 16 deletions
+2 -2
View File
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.15)
project (tkDNN)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC -Wno-deprecated-declarations -Wno-unused-variable")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC -Wno-deprecated-declarations -Wno-unused-variable -O3")
endif()
if(WIN32)
set(CMAKE_CXX_STANDARD 11)
@@ -31,7 +31,7 @@ endif()
find_package(CUDA 9.0 REQUIRED)
SET(CUDA_SEPARABLE_COMPILATION ON)
#set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -arch=sm_30 --compiler-options '-fPIC'")
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --maxrregcount=32)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --maxrregcount=32 -arch=sm_61)
find_package(CUDNN REQUIRED)
+13 -8
View File
@@ -45,14 +45,14 @@ int main(int argc, char *argv[]) {
if(argc > 2)
cfgPath = argv[2];
cfgPath = argv[3];
if(argc > 3)
namePath = argv[3];
namePath = argv[4];
if(argc > 4)
input = argv[4];
input = argv[5];
char ntype = 'y';
if(argc > 5)
ntype = argv[5][0];
ntype = argv[2][0];
int n_classes = 80;
if(argc > 6)
n_classes = atoi(argv[6]);
@@ -72,9 +72,14 @@ int main(int argc, char *argv[]) {
if(!show)
SAVE_RESULT = true;
if(ntype == 'c' || ntype == 'm'){
cfgPath = nullptr;
namePath = nullptr;
}
tk::dnn::Yolo3Detection yolo;
//tk::dnn::CenternetDetection cnet;
//tk::dnn::MobilenetDetection mbnet;
tk::dnn::CenternetDetection cnet;
tk::dnn::MobilenetDetection mbnet;
tk::dnn::DetectionNN *detNN;
@@ -84,10 +89,10 @@ int main(int argc, char *argv[]) {
detNN = &yolo;
break;
case 'c':
//detNN = &cnet;
detNN = &cnet;
break;
case 'm':
//detNN = &mbnet;
detNN = &mbnet;
n_classes++;
break;
default:
+1 -1
View File
@@ -73,7 +73,7 @@ public:
CenternetDetection() {};
~CenternetDetection() {};
bool init(const std::string& tensor_path, const int n_classes=80, const int n_batches=1, const float conf_thresh=0.3);
bool init(const std::string& tensor_path,const std::string& cfg_path,const std::string& name_path, const int n_classes=80, const int n_batches=1, const float conf_thresh=0.3);
void preprocess(cv::Mat &frame, const int bi=0);
void postprocess(const int bi=0,const bool mAP=false);
};
+1 -1
View File
@@ -65,7 +65,7 @@ public:
MobilenetDetection() {};
~MobilenetDetection() {};
bool init(const std::string& tensor_path, const int n_classes, const int n_batches=1, const float conf_thresh=0.3);
bool init(const std::string& tensor_path, const std::string& cfg_path,const std::string& name_path,const int n_classes, const int n_batches=1, const float conf_thresh=0.3);
void preprocess(cv::Mat &frame, const int bi=0);
void postprocess(const int bi=0,const bool mAP=false);
};
+1 -1
View File
@@ -3,7 +3,7 @@
namespace tk { namespace dnn {
bool CenternetDetection::init(const std::string& tensor_path, const int n_classes, const int n_batches, const float conf_thresh){
bool CenternetDetection::init(const std::string& tensor_path, const std::string& cfg_path,const std::string& name_path,const int n_classes, const int n_batches, const float conf_thresh){
std::cout<<(tensor_path).c_str()<<"\n";
netRT = new tk::dnn::NetworkRT(NULL, (tensor_path).c_str() );
classes = n_classes;
+1 -1
View File
@@ -126,7 +126,7 @@ float MobilenetDetection::iou(const tk::dnn::box &a, const tk::dnn::box &b){
return iou;
}
bool MobilenetDetection::init(const std::string& tensor_path, const int n_classes, const int n_batches, const float conf_thresh){
bool MobilenetDetection::init(const std::string& tensor_path, const std::string& cfg_path,const std::string& name_path,const int n_classes, const int n_batches, const float conf_thresh){
std::cout<<(tensor_path).c_str()<<"\n";
netRT = new tk::dnn::NetworkRT(NULL, (tensor_path).c_str());
imageSize = netRT->input_dim.h;
+1 -1
View File
@@ -657,8 +657,8 @@ bool NetworkRT::deserialize(const char *filename) {
void NetworkRT::destroy() {
contextRT->destroy();
configRT->destroy();
engineRT->destroy();
configRT->destroy();
builderRT->destroy();
}
+1 -1
View File
@@ -29,7 +29,7 @@ namespace tk { namespace dnn {
for(int i=0; i<noYolos.size(); i++) {
std::vector<float> maskTemp,anchorsTemp;
std::vector<std::string> classNamesTemp;
int classes,nms_kind,coords,numTemp;
int nms_kind,coords,numTemp;
float nmsthresh;
loadYoloInfo(cfg_path,yolosLine[i],maskTemp,anchorsTemp,numTemp,classes,nmsthresh,nms_kind,coords);
classNamesTemp = darknetReadNames(name_path);
+1
View File
@@ -29,6 +29,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
@@ -29,6 +29,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -27,6 +27,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -28,6 +28,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -29,6 +29,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -41,6 +41,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -29,6 +29,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -29,6 +29,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -29,6 +29,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -28,6 +28,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -41,6 +41,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -29,6 +29,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -29,6 +29,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -29,6 +29,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -42,6 +42,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -29,6 +29,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -29,6 +29,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -29,6 +29,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -29,6 +29,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -40,6 +40,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
+1
View File
@@ -31,6 +31,7 @@ int main() {
int ret = testInference(input_bins, output_bins, net, netRT);
net->releaseLayers();
delete net;
netRT->destroy();
delete netRT;
return ret;
}
@@ -542,5 +542,6 @@ int main()
ret_cudnn_tensorrt |= checkResult(conf->output_dim.tot(), conf->dstData, rt_out3) == 0 ? 0 : ERROR_CUDNNvsTENSORRT;
ret_cudnn_tensorrt |= checkResult(loc->output_dim.tot(), loc->dstData, rt_out4) == 0 ? 0 : ERROR_CUDNNvsTENSORRT;
netRT.destroy();
return ret_cudnn | ret_tensorrt | ret_cudnn_tensorrt;
}