diff --git a/demo/demo/demo.cpp b/demo/demo/demo.cpp index 3a9ef6e..ba08caa 100644 --- a/demo/demo/demo.cpp +++ b/demo/demo/demo.cpp @@ -97,6 +97,13 @@ int main(int argc, char *argv[]) { } std::cout<<"detection end\n"; + + + std::cout< detected; + // keep track of inference times (ms) + std::vector stats; + Yolo3Detection() {} virtual ~Yolo3Detection() {} diff --git a/include/tkDNN/tkdnn.h b/include/tkDNN/tkdnn.h index dde3126..554daa1 100644 --- a/include/tkDNN/tkdnn.h +++ b/include/tkDNN/tkdnn.h @@ -5,4 +5,4 @@ #include "Layer.h" #include "NetworkRT.h" -#define TKDNN_VERSION 300 +#define TKDNN_VERSION 400 diff --git a/src/NetworkRT.cpp b/src/NetworkRT.cpp index 7430b6f..d4fdf90 100644 --- a/src/NetworkRT.cpp +++ b/src/NetworkRT.cpp @@ -35,7 +35,7 @@ NetworkRT::NetworkRT(Network *net, const char *name) { builderRT = createInferBuilder(loggerRT); std::cout<<"Float16 support: "<platformHasFastFp16()<<"\n"; std::cout<<"Int8 support: "<platformHasFastInt8()<<"\n"; - //std::cout<<"DLAs: "<getNbDLACores()<<"\n"; + std::cout<<"DLAs: "<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, @@ -276,10 +274,19 @@ ILayer* NetworkRT::convert_layer(ITensor *input, Activation *l) { if(l->act_mode == ACTIVATION_LEAKY) { //std::cout<<"New plugin LEAKY\n"; + + /* + // plugin version IPlugin *plugin = new ActivationLeakyRT(); IPluginLayer *lRT = networkRT->addPlugin(&input, 1, *plugin); checkNULL(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) { 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<<"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; } diff --git a/src/Yolo3Detection.cpp b/src/Yolo3Detection.cpp index ed392f7..869c792 100644 --- a/src/Yolo3Detection.cpp +++ b/src/Yolo3Detection.cpp @@ -94,6 +94,8 @@ void Yolo3Detection::update(cv::Mat &imageORIG) { netRT->infer(dim, input_d); TIMER_STOP dim.print(); + + stats.push_back(t_ns); } TIMER_START