From 30f65c2523daaad970d3147c2906985a35b986cc Mon Sep 17 00:00:00 2001 From: wenbin Date: Mon, 25 Apr 2022 15:57:23 +0800 Subject: [PATCH] int8 clone issue fix (#42218) --- paddle/fluid/framework/naive_executor.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/paddle/fluid/framework/naive_executor.cc b/paddle/fluid/framework/naive_executor.cc index f30d1ea1b83..dba3b3ff1e6 100644 --- a/paddle/fluid/framework/naive_executor.cc +++ b/paddle/fluid/framework/naive_executor.cc @@ -147,11 +147,16 @@ void NaiveExecutor::ResetTrtOps(int num) { int engine_predictor_id = trtop->Attr("predictor_id"); std::string engine_name = engine_key + std::to_string(engine_predictor_id); - operators::TensorRTEngine *trt_engine = - paddle::inference::Singleton< + operators::TensorRTEngine *trt_engine = nullptr; + // can't get trt engine if int8 calibration table data process. + if (paddle::inference::Singleton< inference::tensorrt::TRTEngineManager>::Global() - .Get(engine_name); - if (trt_engine->with_dynamic_shape()) { + .Has(engine_name)) { + trt_engine = paddle::inference::Singleton< + inference::tensorrt::TRTEngineManager>::Global() + .Get(engine_name); + } + if (trt_engine && trt_engine->with_dynamic_shape()) { LOG(INFO) << "rebuild trt engine, this may cost a lot of time!"; trt_engine->ResetContext(); trt_engine->ClearTensorMap(); -- GitLab