diff --git a/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h b/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h index 3713632511fc8bc207e8651af9f3c8634b6afd68..0f8a3d1206264665597314b7a7ae53ee7fb456ab 100644 --- a/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h +++ b/paddle/fluid/operators/tensorrt/tensorrt_engine_op.h @@ -495,6 +495,11 @@ class TensorRTEngineOp : public framework::OperatorBase { // Bind input tensor to TRT. for (const auto &x : runtime_input_names_) { +#if IS_TRT_VERSION_LT(8000) + // trt may remove input tensor if it's unused or used only at compile-time + if (engine->engine()->getBindingIndex(x.c_str()) < 0) continue; +#endif + // convert input and copy to TRT engine's buffer auto &t = inference::analysis::GetFromScope(scope, x);