shared_ptr migrations
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.5)
|
|||||||
project (tkDNN)
|
project (tkDNN)
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -Wno-deprecated-declarations -Wno-unused-variable")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC -Wno-deprecated-declarations -Wno-unused-variable")
|
||||||
endif()
|
endif()
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "Network.h"
|
#include "Network.h"
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "NvInfer.h"
|
#include "NvInfer.h"
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace tk { namespace dnn {
|
namespace tk { namespace dnn {
|
||||||
|
|
||||||
@@ -59,7 +60,8 @@ public:
|
|||||||
#if NV_TENSORRT_MAJOR >= 6
|
#if NV_TENSORRT_MAJOR >= 6
|
||||||
nvinfer1::IBuilderConfig *configRT;
|
nvinfer1::IBuilderConfig *configRT;
|
||||||
#endif
|
#endif
|
||||||
nvinfer1::ICudaEngine *engineRT;
|
std::shared_ptr<nvinfer1::ICudaEngine> engineRT;
|
||||||
|
//nvinfer1::ICudaEngine *engineRT;
|
||||||
nvinfer1::IExecutionContext *contextRT;
|
nvinfer1::IExecutionContext *contextRT;
|
||||||
|
|
||||||
const static int MAX_BUFFERS_RT = 10;
|
const static int MAX_BUFFERS_RT = 10;
|
||||||
@@ -114,6 +116,9 @@ public:
|
|||||||
|
|
||||||
bool serialize(const char *filename);
|
bool serialize(const char *filename);
|
||||||
bool deserialize(const char *filename);
|
bool deserialize(const char *filename);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -110,6 +110,17 @@ double t_ns = time_ms.count();
|
|||||||
FatalError(_error.str()); \
|
FatalError(_error.str()); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
struct InferDeleter
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
void operator()(T* obj) const
|
||||||
|
{
|
||||||
|
if (obj)
|
||||||
|
{
|
||||||
|
obj->destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ERROR_CUDNN = 2,
|
ERROR_CUDNN = 2,
|
||||||
|
|||||||
+7
-4
@@ -137,9 +137,11 @@ NetworkRT::NetworkRT(Network *net, const char *name) {
|
|||||||
printCudaMemUsage();
|
printCudaMemUsage();
|
||||||
std::cout<<"Building tensorRT cuda engine...\n";
|
std::cout<<"Building tensorRT cuda engine...\n";
|
||||||
#if NV_TENSORRT_MAJOR >= 6
|
#if NV_TENSORRT_MAJOR >= 6
|
||||||
engineRT = builderRT->buildEngineWithConfig(*networkRT, *configRT);
|
//engineRT = builderRT->buildEngineWithConfig(*networkRT, *configRT);
|
||||||
|
engineRT = std::shared_ptr<nvinfer1::ICudaEngine>(builderRT->buildEngineWithConfig(*networkRT,*configRT),InferDeleter());
|
||||||
#else
|
#else
|
||||||
engineRT = builderRT->buildCudaEngine(*networkRT);
|
//engineRT = builderRT->buildCudaEngine(*networkRT);
|
||||||
|
engineRT = std::shared_ptr<nvinfer1::ICudaEngine>(builderRT->buildCudaEngine(*networkRT));
|
||||||
#endif
|
#endif
|
||||||
if(engineRT == nullptr)
|
if(engineRT == nullptr)
|
||||||
FatalError("cloud not build cuda engine")
|
FatalError("cloud not build cuda engine")
|
||||||
@@ -561,7 +563,7 @@ ILayer* NetworkRT::convert_layer(ITensor *input, DeformConv2d *l) {
|
|||||||
IPluginLayer *lRT = networkRT->addPlugin(inputs, 2, *plugin);
|
IPluginLayer *lRT = networkRT->addPlugin(inputs, 2, *plugin);
|
||||||
checkNULL(lRT);
|
checkNULL(lRT);
|
||||||
lRT->setName( ("Deformable" + std::to_string(l->id)).c_str() );
|
lRT->setName( ("Deformable" + std::to_string(l->id)).c_str() );
|
||||||
delete(inputs);
|
delete[](inputs);
|
||||||
// batchnorm
|
// batchnorm
|
||||||
void *bias_b, *power_b, *mean_b, *variance_b, *scales_b;
|
void *bias_b, *power_b, *mean_b, *variance_b, *scales_b;
|
||||||
if(dtRT == DataType::kHALF) {
|
if(dtRT == DataType::kHALF) {
|
||||||
@@ -629,7 +631,8 @@ bool NetworkRT::deserialize(const char *filename) {
|
|||||||
|
|
||||||
pluginFactory = new PluginFactory();
|
pluginFactory = new PluginFactory();
|
||||||
runtimeRT = createInferRuntime(loggerRT);
|
runtimeRT = createInferRuntime(loggerRT);
|
||||||
engineRT = runtimeRT->deserializeCudaEngine(gieModelStream, size, (IPluginFactory *) pluginFactory);
|
//engineRT = runtimeRT->deserializeCudaEngine(gieModelStream, size, (IPluginFactory *) pluginFactory);
|
||||||
|
engineRT = std::shared_ptr<nvinfer1::ICudaEngine>(runtimeRT->deserializeCudaEngine(gieModelStream,size,(IPluginFactory*)pluginFactory),InferDeleter());
|
||||||
//if (gieModelStream) delete [] gieModelStream;
|
//if (gieModelStream) delete [] gieModelStream;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user