Merge branch 'master' of https://github.com/ceccocats/tkDNN into cnet
This commit is contained in:
@@ -49,3 +49,4 @@ this will genereate a yolo3_berkeley.rt file that can be used for live detection
|
||||
./yolo3_demo # launch detection on a demo video
|
||||
./yolo3_demo yolo3_berkeley.rt /dev/video0 # launch detection on device 0
|
||||
```
|
||||

|
||||
|
||||
@@ -101,6 +101,13 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ class Yolo3Detection {
|
||||
// this is filled with results
|
||||
std::vector<tk::dnn::box> detected;
|
||||
|
||||
// keep track of inference times (ms)
|
||||
std::vector<double> stats;
|
||||
|
||||
Yolo3Detection() {}
|
||||
|
||||
virtual ~Yolo3Detection() {}
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
#include "Layer.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);
|
||||
std::cout<<"Float16 support: "<<builderRT->platformHasFastFp16()<<"\n";
|
||||
std::cout<<"Int8 support: "<<builderRT->platformHasFastInt8()<<"\n";
|
||||
//std::cout<<"DLAs: "<<builderRT->getNbDLACores()<<"\n";
|
||||
std::cout<<"DLAs: "<<builderRT->getNbDLACores()<<"\n";
|
||||
networkRT = builderRT->createNetwork();
|
||||
|
||||
if(!fileExist(name)) {
|
||||
@@ -51,7 +51,6 @@ NetworkRT::NetworkRT(Network *net, const char *name) {
|
||||
dtRT = DataType::kHALF;
|
||||
builderRT->setHalf2Mode(true);
|
||||
}
|
||||
/*
|
||||
if(net->dla && builderRT->getNbDLACores() > 0) {
|
||||
dtRT = DataType::kHALF;
|
||||
builderRT->setFp16Mode(true);
|
||||
@@ -59,7 +58,6 @@ NetworkRT::NetworkRT(Network *net, const char *name) {
|
||||
builderRT->setDefaultDeviceType(DeviceType::kDLA);
|
||||
builderRT->setDLACore(0);
|
||||
}
|
||||
*/
|
||||
|
||||
//add input layer
|
||||
ITensor *input = networkRT->addInput("data", DataType::kFLOAT,
|
||||
@@ -316,10 +314,19 @@ ILayer* NetworkRT::convert_layer(ITensor *input, Activation *l) {
|
||||
|
||||
if(l->act_mode == ACTIVATION_LEAKY) {
|
||||
//std::cout<<"New plugin LEAKY\n";
|
||||
|
||||
#if NV_TENSORRT_MAJOR < 6
|
||||
// plugin version
|
||||
IPlugin *plugin = new ActivationLeakyRT();
|
||||
IPluginLayer *lRT = networkRT->addPlugin(&input, 1, *plugin);
|
||||
checkNULL(lRT);
|
||||
return lRT;
|
||||
#else
|
||||
IActivationLayer *lRT = networkRT->addActivation(*input, ActivationType::kLEAKY_RELU);
|
||||
lRT->setAlpha(0.1);
|
||||
checkNULL(lRT);
|
||||
return lRT;
|
||||
#endif
|
||||
|
||||
} else if(l->act_mode == CUDNN_ACTIVATION_RELU) {
|
||||
IActivationLayer *lRT = networkRT->addActivation(*input, ActivationType::kRELU);
|
||||
@@ -391,14 +398,21 @@ ILayer* NetworkRT::convert_layer(ITensor *input, Shortcut *l) {
|
||||
//std::cout<<"convert Shortcut\n";
|
||||
|
||||
//std::cout<<"New plugin Shortcut\n";
|
||||
|
||||
ITensor *back_tens = tensors[l->backLayer];
|
||||
/*
|
||||
// plugin version
|
||||
IPlugin *plugin = new ShortcutRT();
|
||||
|
||||
ITensor **inputs = new ITensor*[2];
|
||||
inputs[0] = input;
|
||||
inputs[1] = back_tens;
|
||||
IPluginLayer *lRT = networkRT->addPlugin(inputs, 2, *plugin);
|
||||
checkNULL(lRT);
|
||||
*/
|
||||
|
||||
IElementWiseLayer *lRT = networkRT->addElementWise(*input, *back_tens, ElementWiseOperation::kSUM);
|
||||
checkNULL(lRT);
|
||||
|
||||
return lRT;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,8 @@ void Yolo3Detection::update(cv::Mat &imageORIG) {
|
||||
netRT->infer(dim, input_d);
|
||||
TIMER_STOP
|
||||
dim.print();
|
||||
|
||||
stats.push_back(t_ns);
|
||||
}
|
||||
|
||||
TIMER_START
|
||||
|
||||
Reference in New Issue
Block a user