add DLA, plugin for shortcut and leaky. new verison 0.4
This commit is contained in:
@@ -97,6 +97,13 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::cout<<"detection end\n";
|
std::cout<<"detection end\n";
|
||||||
|
|
||||||
|
|
||||||
|
std::cout<<COL_GREENB<<"\n\nTime stats:\n";
|
||||||
|
std::cout<<"Min: "<<*std::min_element(yolo.stats.begin(), yolo.stats.end())<<" ms\n";
|
||||||
|
std::cout<<"Max: "<<*std::max_element(yolo.stats.begin(), yolo.stats.end())<<" ms\n";
|
||||||
|
double mean = 0; for(int i=0; i<yolo.stats.size(); i++) mean += yolo.stats[i]; mean /= yolo.stats.size();
|
||||||
|
std::cout<<"Avg: "<<mean<<" ms\n"<<COL_END;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ class Yolo3Detection {
|
|||||||
// this is filled with results
|
// this is filled with results
|
||||||
std::vector<tk::dnn::box> detected;
|
std::vector<tk::dnn::box> detected;
|
||||||
|
|
||||||
|
// keep track of inference times (ms)
|
||||||
|
std::vector<double> stats;
|
||||||
|
|
||||||
Yolo3Detection() {}
|
Yolo3Detection() {}
|
||||||
|
|
||||||
virtual ~Yolo3Detection() {}
|
virtual ~Yolo3Detection() {}
|
||||||
|
|||||||
@@ -5,4 +5,4 @@
|
|||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "NetworkRT.h"
|
#include "NetworkRT.h"
|
||||||
|
|
||||||
#define TKDNN_VERSION 300
|
#define TKDNN_VERSION 400
|
||||||
|
|||||||
+18
-4
@@ -35,7 +35,7 @@ NetworkRT::NetworkRT(Network *net, const char *name) {
|
|||||||
builderRT = createInferBuilder(loggerRT);
|
builderRT = createInferBuilder(loggerRT);
|
||||||
std::cout<<"Float16 support: "<<builderRT->platformHasFastFp16()<<"\n";
|
std::cout<<"Float16 support: "<<builderRT->platformHasFastFp16()<<"\n";
|
||||||
std::cout<<"Int8 support: "<<builderRT->platformHasFastInt8()<<"\n";
|
std::cout<<"Int8 support: "<<builderRT->platformHasFastInt8()<<"\n";
|
||||||
//std::cout<<"DLAs: "<<builderRT->getNbDLACores()<<"\n";
|
std::cout<<"DLAs: "<<builderRT->getNbDLACores()<<"\n";
|
||||||
networkRT = builderRT->createNetwork();
|
networkRT = builderRT->createNetwork();
|
||||||
|
|
||||||
if(!fileExist(name)) {
|
if(!fileExist(name)) {
|
||||||
@@ -51,7 +51,6 @@ NetworkRT::NetworkRT(Network *net, const char *name) {
|
|||||||
dtRT = DataType::kHALF;
|
dtRT = DataType::kHALF;
|
||||||
builderRT->setHalf2Mode(true);
|
builderRT->setHalf2Mode(true);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if(net->dla && builderRT->getNbDLACores() > 0) {
|
if(net->dla && builderRT->getNbDLACores() > 0) {
|
||||||
dtRT = DataType::kHALF;
|
dtRT = DataType::kHALF;
|
||||||
builderRT->setFp16Mode(true);
|
builderRT->setFp16Mode(true);
|
||||||
@@ -59,7 +58,6 @@ NetworkRT::NetworkRT(Network *net, const char *name) {
|
|||||||
builderRT->setDefaultDeviceType(DeviceType::kDLA);
|
builderRT->setDefaultDeviceType(DeviceType::kDLA);
|
||||||
builderRT->setDLACore(0);
|
builderRT->setDLACore(0);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
//add input layer
|
//add input layer
|
||||||
ITensor *input = networkRT->addInput("data", DataType::kFLOAT,
|
ITensor *input = networkRT->addInput("data", DataType::kFLOAT,
|
||||||
@@ -276,10 +274,19 @@ ILayer* NetworkRT::convert_layer(ITensor *input, Activation *l) {
|
|||||||
|
|
||||||
if(l->act_mode == ACTIVATION_LEAKY) {
|
if(l->act_mode == ACTIVATION_LEAKY) {
|
||||||
//std::cout<<"New plugin LEAKY\n";
|
//std::cout<<"New plugin LEAKY\n";
|
||||||
|
|
||||||
|
/*
|
||||||
|
// plugin version
|
||||||
IPlugin *plugin = new ActivationLeakyRT();
|
IPlugin *plugin = new ActivationLeakyRT();
|
||||||
IPluginLayer *lRT = networkRT->addPlugin(&input, 1, *plugin);
|
IPluginLayer *lRT = networkRT->addPlugin(&input, 1, *plugin);
|
||||||
checkNULL(lRT);
|
checkNULL(lRT);
|
||||||
return lRT;
|
return lRT;
|
||||||
|
*/
|
||||||
|
|
||||||
|
IActivationLayer *lRT = networkRT->addActivation(*input, ActivationType::kLEAKY_RELU);
|
||||||
|
lRT->setAlpha(0.1);
|
||||||
|
checkNULL(lRT);
|
||||||
|
return lRT;
|
||||||
|
|
||||||
} else if(l->act_mode == CUDNN_ACTIVATION_RELU) {
|
} else if(l->act_mode == CUDNN_ACTIVATION_RELU) {
|
||||||
IActivationLayer *lRT = networkRT->addActivation(*input, ActivationType::kRELU);
|
IActivationLayer *lRT = networkRT->addActivation(*input, ActivationType::kRELU);
|
||||||
@@ -340,14 +347,21 @@ ILayer* NetworkRT::convert_layer(ITensor *input, Shortcut *l) {
|
|||||||
//std::cout<<"convert Shortcut\n";
|
//std::cout<<"convert Shortcut\n";
|
||||||
|
|
||||||
//std::cout<<"New plugin Shortcut\n";
|
//std::cout<<"New plugin Shortcut\n";
|
||||||
|
|
||||||
ITensor *back_tens = tensors[l->backLayer];
|
ITensor *back_tens = tensors[l->backLayer];
|
||||||
|
/*
|
||||||
|
// plugin version
|
||||||
IPlugin *plugin = new ShortcutRT();
|
IPlugin *plugin = new ShortcutRT();
|
||||||
|
|
||||||
ITensor **inputs = new ITensor*[2];
|
ITensor **inputs = new ITensor*[2];
|
||||||
inputs[0] = input;
|
inputs[0] = input;
|
||||||
inputs[1] = back_tens;
|
inputs[1] = back_tens;
|
||||||
IPluginLayer *lRT = networkRT->addPlugin(inputs, 2, *plugin);
|
IPluginLayer *lRT = networkRT->addPlugin(inputs, 2, *plugin);
|
||||||
checkNULL(lRT);
|
checkNULL(lRT);
|
||||||
|
*/
|
||||||
|
|
||||||
|
IElementWiseLayer *lRT = networkRT->addElementWise(*input, *back_tens, ElementWiseOperation::kSUM);
|
||||||
|
checkNULL(lRT);
|
||||||
|
|
||||||
return lRT;
|
return lRT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ void Yolo3Detection::update(cv::Mat &imageORIG) {
|
|||||||
netRT->infer(dim, input_d);
|
netRT->infer(dim, input_d);
|
||||||
TIMER_STOP
|
TIMER_STOP
|
||||||
dim.print();
|
dim.print();
|
||||||
|
|
||||||
|
stats.push_back(t_ns);
|
||||||
}
|
}
|
||||||
|
|
||||||
TIMER_START
|
TIMER_START
|
||||||
|
|||||||
Reference in New Issue
Block a user