From 0f6efdcae7de08f09e8a78ea2799af65b636d3bc Mon Sep 17 00:00:00 2001 From: yf711 Date: Tue, 30 Jul 2024 16:40:28 -0700 Subject: [PATCH] check if trt_engine invalid --- .../core/providers/tensorrt/tensorrt_execution_provider.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc index cdbb7bb2a8094..7178963fb5acd 100644 --- a/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc +++ b/onnxruntime/core/providers/tensorrt/tensorrt_execution_provider.cc @@ -3672,6 +3672,10 @@ Status TensorrtExecutionProvider::CreateNodeComputeInfoFromGraph(const GraphView return ORT_MAKE_STATUS(ONNXRUNTIME, EP_FAIL, "TensorRT EP Failed to Build Engine."); } trt_engine = trt_state->engine->get(); + // Check before using trt_engine + if (trt_engine == nullptr) { + return ORT_MAKE_STATUS(ONNXRUNTIME, EP_FAIL, "Invalid TensorRT engine, please rebuild."); + } if (trt_state->engine_cache_enable) { // Serialize engine profile SerializeProfileV2(profile_cache_path, shape_ranges);