[TensorRT EP] Add null_ptr check to avoid crash when running session which was failed to generate trt_engine previously (#21621)
### Description <!-- Describe your changes. --> Add null_ptr check to avoid crash when running session which was failed to generate trt_engine previously ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> Reported and verified by https://github.com/microsoft/onnxruntime/issues/21567
This commit is contained in:
Родитель
88788474b9
Коммит
906ae77eea
|
@ -3752,6 +3752,11 @@ Status TensorrtExecutionProvider::CreateNodeComputeInfoFromGraph(const GraphView
|
|||
trt_context = trt_state->context->get();
|
||||
}
|
||||
|
||||
// Check before using trt_engine
|
||||
if (trt_engine == nullptr) {
|
||||
return ORT_MAKE_STATUS(ONNXRUNTIME, EP_FAIL, "No engine is found.");
|
||||
}
|
||||
|
||||
// Get input and output binding names
|
||||
int total_bindings = trt_engine->getNbIOTensors();
|
||||
std::vector<char const*> input_binding_names, output_binding_names;
|
||||
|
@ -4075,6 +4080,11 @@ Status TensorrtExecutionProvider::CreateNodeComputeInfoFromPrecompiledEngine(con
|
|||
Ort::ThrowOnError(api->KernelContext_GetGPUComputeStream(context, &cuda_stream));
|
||||
cudaStream_t stream = static_cast<cudaStream_t>(cuda_stream);
|
||||
|
||||
// Check before using trt_engine
|
||||
if (trt_engine == nullptr) {
|
||||
return ORT_MAKE_STATUS(ONNXRUNTIME, EP_FAIL, "No engine is found.");
|
||||
}
|
||||
|
||||
// Get input and output binding names
|
||||
int total_bindings = trt_engine->getNbIOTensors();
|
||||
std::vector<char const*> input_binding_names, output_binding_names;
|
||||
|
|
Загрузка…
Ссылка в новой задаче