From cc594f09efdbf0e7c5a33e4e4c40ea24ac2e7048 Mon Sep 17 00:00:00 2001 From: perseusdg Date: Thu, 8 Apr 2021 00:28:00 +0530 Subject: [PATCH] merge from gitlab --- include/tkDNN/NetworkRT.h | 10 ++++------ include/tkDNN/utils.h | 14 -------------- src/NetworkRT.cpp | 37 ++++--------------------------------- src/utils.cpp | 3 +-- 4 files changed, 9 insertions(+), 55 deletions(-) diff --git a/include/tkDNN/NetworkRT.h b/include/tkDNN/NetworkRT.h index b39360c..66892f5 100644 --- a/include/tkDNN/NetworkRT.h +++ b/include/tkDNN/NetworkRT.h @@ -55,16 +55,14 @@ class NetworkRT { public: nvinfer1::DataType dtRT; - //nvinfer1::IBuilder *builderRT; - std::unique_ptr builderRT; - //nvinfer1::IRuntime *runtimeRT; - std::unique_ptr runtimeRT; + nvinfer1::IBuilder *builderRT; + nvinfer1::IRuntime *runtimeRT; nvinfer1::INetworkDefinition *networkRT; #if NV_TENSORRT_MAJOR >= 6 nvinfer1::IBuilderConfig *configRT; #endif - std::shared_ptr engineRT; - //nvinfer1::ICudaEngine *engineRT; + + nvinfer1::ICudaEngine *engineRT; nvinfer1::IExecutionContext *contextRT; const static int MAX_BUFFERS_RT = 10; diff --git a/include/tkDNN/utils.h b/include/tkDNN/utils.h index ce4a617..eeef3c2 100644 --- a/include/tkDNN/utils.h +++ b/include/tkDNN/utils.h @@ -14,9 +14,6 @@ #ifdef __linux__ #include -#elif _WIN32 -#define NOMINMAX -#include #endif #include @@ -110,17 +107,6 @@ double t_ns = time_ms.count(); FatalError(_error.str()); \ } \ } -struct InferDeleter -{ - template - void operator()(T* obj) const - { - if (obj) - { - obj->destroy(); - } - } -}; typedef enum { ERROR_CUDNN = 2, diff --git a/src/NetworkRT.cpp b/src/NetworkRT.cpp index 1e0b062..b5005db 100644 --- a/src/NetworkRT.cpp +++ b/src/NetworkRT.cpp @@ -33,8 +33,7 @@ NetworkRT::NetworkRT(Network *net, const char *name) { float(NV_TENSORRT_PATCH)/100; std::cout<<"New NetworkRT (TensorRT v"<(createInferBuilder(loggerRT)); - //builderRT = createInferBuilder(loggerRT); + builderRT = createInferBuilder(loggerRT); std::cout<<"Float16 support: "<platformHasFastFp16()<<"\n"; std::cout<<"Int8 support: "<platformHasFastInt8()<<"\n"; #if NV_TENSORRT_MAJOR >= 5 @@ -138,8 +137,7 @@ NetworkRT::NetworkRT(Network *net, const char *name) { printCudaMemUsage(); std::cout<<"Building tensorRT cuda engine...\n"; #if NV_TENSORRT_MAJOR >= 6 - //engineRT = builderRT->buildEngineWithConfig(*networkRT, *configRT); - engineRT = std::shared_ptr(builderRT->buildEngineWithConfig(*networkRT,*configRT),InferDeleter()); + engineRT = builderRT->buildEngineWithConfig(*networkRT, *configRT); #else //engineRT = builderRT->buildCudaEngine(*networkRT); engineRT = std::shared_ptr(builderRT->buildCudaEngine(*networkRT)); @@ -637,10 +635,8 @@ bool NetworkRT::deserialize(const char *filename) { } pluginFactory = new PluginFactory(); - //runtimeRT = createInferRuntime(loggerRT); - runtimeRT = std::unique_ptr(createInferRuntime(loggerRT)); - //engineRT = runtimeRT->deserializeCudaEngine(gieModelStream, size, (IPluginFactory *) pluginFactory); - engineRT = std::shared_ptr(runtimeRT->deserializeCudaEngine(gieModelStream,size,(IPluginFactory*)pluginFactory),InferDeleter()); + runtimeRT = createInferRuntime(loggerRT); + engineRT = runtimeRT->deserializeCudaEngine(gieModelStream, size, (IPluginFactory *) pluginFactory); //if (gieModelStream) delete [] gieModelStream; return true; @@ -673,7 +669,6 @@ IPlugin* PluginFactory::createPlugin(const char* layerName, const void* serialDa } if(name.find("ActivationCReLU") == 0) { float activationReluTemp = readBUF(buf); - //ActivationReLUCeiling *a = new ActivationReLUCeiling(readBUF(buf)); ActivationReLUCeiling* a = new ActivationReLUCeiling(activationReluTemp); a->size = readBUF(buf); assert(buf == bufCheck + serialLength); @@ -684,9 +679,6 @@ IPlugin* PluginFactory::createPlugin(const char* layerName, const void* serialDa int classesTemp = readBUF(buf); int coordsTemp = readBUF(buf); int numTemp = readBUF(buf); - /*RegionRT *r = new RegionRT(readBUF(buf), //classes - readBUF(buf), //coords - readBUF(buf)); //num8*/ RegionRT* r = new RegionRT(classesTemp, coordsTemp, numTemp); r->c = readBUF(buf); @@ -698,7 +690,6 @@ IPlugin* PluginFactory::createPlugin(const char* layerName, const void* serialDa if(name.find("Reorg") == 0) { int strideTemp = readBUF(buf); - //ReorgRT *r = new ReorgRT(readBUF(buf)); //stride ReorgRT *r = new ReorgRT(strideTemp); r->c = readBUF(buf); r->h = readBUF(buf); @@ -723,15 +714,6 @@ IPlugin* PluginFactory::createPlugin(const char* layerName, const void* serialDa } if(name.find("Pooling") == 0) { - /* MaxPoolFixedSizeRT *r = new MaxPoolFixedSizeRT( readBUF(buf), //c - readBUF(buf), //h - readBUF(buf), //w - readBUF(buf), //n - readBUF(buf), //strideH - readBUF(buf), //strideW - readBUF(buf), //winSize - readBUF(buf)); //padding*/ - int cTemp = readBUF(buf); int hTemp = readBUF(buf); int wTemp = readBUF(buf); @@ -747,9 +729,6 @@ IPlugin* PluginFactory::createPlugin(const char* layerName, const void* serialDa } if(name.find("Resize") == 0) { - /*ResizeLayerRT *r = new ResizeLayerRT(readBUF(buf), //o_c - readBUF(buf), //o_h - readBUF(buf)); //o_w*/ int o_cTemp = readBUF(buf); int o_hTemp = readBUF(buf); int o_wTemp = readBUF(buf); @@ -822,7 +801,6 @@ IPlugin* PluginFactory::createPlugin(const char* layerName, const void* serialDa return r; } if(name.find("Upsample") == 0) { - //UpsampleRT *r = new UpsampleRT(readBUF(buf)); //stride int strideTemp = readBUF(buf); UpsampleRT* r = new UpsampleRT(strideTemp); r->c = readBUF(buf); @@ -833,7 +811,6 @@ IPlugin* PluginFactory::createPlugin(const char* layerName, const void* serialDa } if(name.find("Route") == 0) { - //RouteRT *r = new RouteRT(readBUF(buf),readBUF(buf)); int groupsTemp = readBUF(buf); int group_idTemp = readBUF(buf); RouteRT* r = new RouteRT(groupsTemp, group_idTemp); @@ -848,12 +825,6 @@ IPlugin* PluginFactory::createPlugin(const char* layerName, const void* serialDa } if(name.find("Deformable") == 0) { - /*DeformableConvRT *r = new DeformableConvRT(readBUF(buf), readBUF(buf), readBUF(buf), - readBUF(buf), readBUF(buf), readBUF(buf), - readBUF(buf), readBUF(buf), - readBUF(buf),readBUF(buf),readBUF(buf),readBUF(buf), - readBUF(buf),readBUF(buf),readBUF(buf),readBUF(buf), - nullptr); */ int chuck_dimTemp = readBUF(buf); int khTemp = readBUF(buf); int kwTemp = readBUF(buf); diff --git a/src/utils.cpp b/src/utils.cpp index 52775df..fa6458f 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -203,8 +203,7 @@ void getMemUsage(double& vm_usage_kb, double& resident_set_kb){ #ifdef __linux__ long page_size_kb = sysconf(_SC_PAGE_SIZE) / 1024; // in case x86-64 is configured to use 2MB pages #elif _WIN32 -SYSTEM_INFO sysInfo; - long page_size_kb = sysInfo.dwPageSize/1024; + long page_size_kb = 4096/1024; #endif vm_usage_kb = vsize / 1024.0;