diff --git a/paddle/fluid/framework/naive_executor.cc b/paddle/fluid/framework/naive_executor.cc index f30d1ea1b83dde65bdb703d511d0246fe4886113..dba3b3ff1e6900a343fc2ff48dfb5f222257bc58 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();