From bef4afa6de6f83c5004ab427a7a5e8ad3a0124de Mon Sep 17 00:00:00 2001 From: Jeng Bai-Cheng Date: Mon, 15 Jun 2020 20:02:38 +0800 Subject: [PATCH] bugfix for unique_ptr of IOptimizationProfile (#23917) This commit fixs the compiling bug regarding unique_ptr of IOptimizationProfile. IOptimizationProfile has protected dtor and is controlled by TensorRT internally. Application shouldn't delete the pointer of IOptimizationProfile. See TensorRT document: https://docs.nvidia.com/deeplearning/sdk/tensorrt-api/c_api/classnvinfer1_1_1_i_builder.html#a9ac47e100454151d8206ac91d543299a test=develop --- paddle/fluid/inference/tensorrt/engine.cc | 4 ++-- paddle/fluid/inference/tensorrt/engine.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/inference/tensorrt/engine.cc b/paddle/fluid/inference/tensorrt/engine.cc index 011d9a25fa4..b6c23d0d7b8 100644 --- a/paddle/fluid/inference/tensorrt/engine.cc +++ b/paddle/fluid/inference/tensorrt/engine.cc @@ -39,7 +39,7 @@ void TensorRTEngine::InitNetwork() { nvinfer1::NetworkDefinitionCreationFlag::kEXPLICIT_BATCH))); infer_builder_config_.reset(infer_builder_->createBuilderConfig()); infer_ptr infer_builder_config_; - optim_profile_.reset(infer_builder_->createOptimizationProfile()); + optim_profile_ = infer_builder_->createOptimizationProfile(); #endif } else { infer_network_.reset(infer_builder_->createNetwork()); @@ -160,7 +160,7 @@ void TensorRTEngine::FreezeNetwork() { input.first.c_str(), nvinfer1::OptProfileSelector::kOPT, Vec2TRT_Dims(optim_input_shape_[input.first], input.first, true)); } - infer_builder_config_->addOptimizationProfile(optim_profile_.get()); + infer_builder_config_->addOptimizationProfile(optim_profile_); if (WithFp16()) { infer_builder_config_->setFlag(nvinfer1::BuilderFlag::kFP16); if (disable_trt_plugin_fp16()) { diff --git a/paddle/fluid/inference/tensorrt/engine.h b/paddle/fluid/inference/tensorrt/engine.h index 03fd7a283b4..0a4f1c94f90 100644 --- a/paddle/fluid/inference/tensorrt/engine.h +++ b/paddle/fluid/inference/tensorrt/engine.h @@ -340,7 +340,7 @@ class TensorRTEngine { infer_ptr infer_networkv2_; #if IS_TRT_VERSION_GE(6000) infer_ptr infer_builder_config_; - std::unique_ptr optim_profile_; + nvinfer1::IOptimizationProfile* optim_profile_; std::vector> owned_pluginv2_; #endif std::mutex mutex_; -- GitLab