This commit is contained in:
Francesco Gatti
2020-01-15 18:07:44 +01:00
6 changed files with 17 additions and 12 deletions
+4 -3
View File
@@ -3,9 +3,10 @@ tkDNN is a Deep Neural Network library built with cuDNN primitives specifically
The main scope is to do high performance inference on already trained models. The main scope is to do high performance inference on already trained models.
this branch actually work on every NVIDIA GPU that support the dependencies: this branch actually work on every NVIDIA GPU that support the dependencies:
* CUDA 9 * CUDA 10.0
* CUDNN 7.105 * CUDNN 7.603
* TENSORRT 4.02 * TENSORRT 6.01
* OPENCV 4.1
## Workflow ## Workflow
The recommended workflow follow these step: The recommended workflow follow these step:
+4 -3
View File
@@ -7,6 +7,7 @@
#include <opencv2/core/core.hpp> #include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp> #include <opencv2/highgui/highgui.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/imgproc/imgproc.hpp> #include <opencv2/imgproc/imgproc.hpp>
#include "Yolo3Detection.h" #include "Yolo3Detection.h"
@@ -46,9 +47,9 @@ int main(int argc, char *argv[]) {
cv::VideoWriter resultVideo; cv::VideoWriter resultVideo;
if(SAVE_RESULT) { if(SAVE_RESULT) {
int w = cap.get(CV_CAP_PROP_FRAME_WIDTH); int w = cap.get(cv::CAP_PROP_FRAME_WIDTH);
int h = cap.get(CV_CAP_PROP_FRAME_HEIGHT); int h = cap.get(cv::CAP_PROP_FRAME_HEIGHT);
resultVideo.open("result.mp4", CV_FOURCC('M','P','4','V'), 30, cv::Size(w, h)); resultVideo.open("result.mp4", cv::VideoWriter::fourcc('M','P','4','V'), 30, cv::Size(w, h));
} }
cv::Mat frame; cv::Mat frame;
+2
View File
@@ -24,6 +24,8 @@ enum layerType_t {
LAYER_YOLO LAYER_YOLO
}; };
#define TKDNN_BN_MIN_EPSILON 1e-5
/** /**
Simple layer Father class Simple layer Father class
*/ */
+1 -1
View File
@@ -117,7 +117,7 @@ dnnType* Conv2d::infer(dataDim_t &dim, dnnType* srcData) {
dstTensorDesc, dstData, dstTensorDesc, dstTensorDesc, dstData, dstTensorDesc,
dstData, biasTensorDesc, //same tensor descriptor as bias dstData, biasTensorDesc, //same tensor descriptor as bias
scales_d, bias_d, mean_d, variance_d, scales_d, bias_d, mean_d, variance_d,
CUDNN_BN_MIN_EPSILON); TKDNN_BN_MIN_EPSILON);
} }
//update data dimensions //update data dimensions
dim = output_dim; dim = output_dim;
+1 -1
View File
@@ -29,7 +29,7 @@ LayerWgs::LayerWgs(Network *net, int inputs, int outputs,
seek += outputs; seek += outputs;
readBinaryFile(weights_path.c_str(), outputs, &variance_h, &variance_d, seek); readBinaryFile(weights_path.c_str(), outputs, &variance_h, &variance_d, seek);
float eps = CUDNN_BN_MIN_EPSILON; float eps = TKDNN_BN_MIN_EPSILON;
power_h = new dnnType[outputs]; power_h = new dnnType[outputs];
for(int i=0; i<outputs; i++) power_h[i] = 1.0f; for(int i=0; i<outputs; i++) power_h[i] = 1.0f;
+5 -4
View File
@@ -17,10 +17,6 @@ Network::Network(dataDim_t input_dim) {
<<", CUDNN v"<<cu_ver<<")\n"; <<", CUDNN v"<<cu_ver<<")\n";
dataType = CUDNN_DATA_FLOAT; dataType = CUDNN_DATA_FLOAT;
tensorFormat = CUDNN_TENSOR_NCHW; tensorFormat = CUDNN_TENSOR_NCHW;
checkCUDNN( cudnnCreate(&cudnnHandle) );
checkERROR( cublasCreate(&cublasHandle) );
num_layers = 0; num_layers = 0;
fp16 = false; fp16 = false;
@@ -38,6 +34,11 @@ Network::Network(dataDim_t input_dim) {
std::cout<<COL_REDB<<"!! FP16 INERENCE ENABLED !!"<<COL_END<<"\n"; std::cout<<COL_REDB<<"!! FP16 INERENCE ENABLED !!"<<COL_END<<"\n";
if(dla) if(dla)
std::cout<<COL_GREENB<<"!! DLA INERENCE ENABLED !!"<<COL_END<<"\n"; std::cout<<COL_GREENB<<"!! DLA INERENCE ENABLED !!"<<COL_END<<"\n";
checkCUDNN( cudnnCreate(&cudnnHandle) );
checkERROR( cublasCreate(&cublasHandle) );
} }
Network::~Network() { Network::~Network() {