From b4a401bbd14effa2b15d4a8946e49e32bbe4f119 Mon Sep 17 00:00:00 2001 From: luoyao Date: Thu, 2 Nov 2023 17:42:51 +0800 Subject: [PATCH] update --- src/models/mono_depth_estimation/metric3d.inl | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/models/mono_depth_estimation/metric3d.inl b/src/models/mono_depth_estimation/metric3d.inl index b5ea4a3..87dd519 100644 --- a/src/models/mono_depth_estimation/metric3d.inl +++ b/src/models/mono_depth_estimation/metric3d.inl @@ -200,9 +200,9 @@ private: std::string model_file_path; // trt context TrtLogger logger; - std::unique_ptr runtime; - std::unique_ptr engine; - std::unique_ptr execution_context; + nvinfer1::IRuntime* runtime = nullptr; + nvinfer1::ICudaEngine* engine = nullptr; + nvinfer1::IExecutionContext* execution_context = nullptr; // trt bindings EngineBinding input_image_binding; EngineBinding output_depth_binding; @@ -669,12 +669,11 @@ template StatusCode Metric3D::Impl::init_trt(const toml::value& cfg) { // init trt runtime _m_trt_params.logger = TrtLogger(); - auto* trt_runtime = nvinfer1::createInferRuntime(_m_trt_params.logger); - if(nullptr == trt_runtime) { + _m_trt_params.runtime = nvinfer1::createInferRuntime(_m_trt_params.logger); + if(nullptr == _m_trt_params.runtime) { LOG(ERROR) << "init tensorrt runtime failed"; return StatusCode::MODEL_INIT_FAILED; } - _m_trt_params.runtime = std::unique_ptr(trt_runtime); // init trt engine if (!cfg.contains("model_file_path")) { @@ -693,15 +692,14 @@ StatusCode Metric3D::Impl::init_trt(const toml::value& cfg) { return StatusCode::MODEL_INIT_FAILED; } auto model_content_length = sizeof(model_file_content[0]) * model_file_content.size(); - _m_trt_params.engine = std::unique_ptr( - _m_trt_params.runtime->deserializeCudaEngine(model_file_content.data(), model_content_length)); + _m_trt_params.engine = _m_trt_params.runtime->deserializeCudaEngine(model_file_content.data(), model_content_length); if (nullptr == _m_trt_params.engine) { LOG(ERROR) << "deserialize trt engine failed"; return StatusCode::MODEL_INIT_FAILED; } // init trt execution context - _m_trt_params.execution_context = std::unique_ptr(_m_trt_params.engine->createExecutionContext()); + _m_trt_params.execution_context = _m_trt_params.engine->createExecutionContext(); if (nullptr == _m_trt_params.execution_context) { LOG(ERROR) << "create trt engine failed"; return StatusCode::MODEL_INIT_FAILED;