Skip to content

Commit c405425

Browse files
OpenVINO EP: Put infer_request back into queue upon catching exception (#679)
1 parent 8eb9687 commit c405425

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

onnxruntime/core/providers/openvino/backends/basic_backend.cc

+2
Original file line numberDiff line numberDiff line change
@@ -761,12 +761,14 @@ void BasicBackend::Infer(OrtKernelContext* ctx) {
761761
try {
762762
StartAsyncInference(context, infer_request);
763763
} catch (const std::runtime_error& e) {
764+
inferRequestsQueue_->putIdleRequest(std::move(infer_request));
764765
ORT_THROW(log_tag + " Exception at StartAsyncInference: " + e.what());
765766
}
766767
#endif
767768
try {
768769
CompleteAsyncInference(context, infer_request);
769770
} catch (const std::runtime_error& e) {
771+
inferRequestsQueue_->putIdleRequest(std::move(infer_request));
770772
ORT_THROW(log_tag + " Exception at CompleteAsyncInference: " + e.what());
771773
}
772774

onnxruntime/core/providers/openvino/ov_interface.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -380,29 +380,29 @@ void OVInferRequest::StartAsync() {
380380
try {
381381
ovInfReq.start_async();
382382
} catch (const Exception& e) {
383-
ORT_THROW(log_tag + " Couldn't start Inference: " + e.what());
383+
throw std::runtime_error(log_tag + " Couldn't start Inference: " + e.what());
384384
} catch (...) {
385-
ORT_THROW(log_tag + " In Error Couldn't start Inference");
385+
throw std::runtime_error(log_tag + " In Error Couldn't start Inference");
386386
}
387387
}
388388

389389
void OVInferRequest::Infer() {
390390
try {
391391
ovInfReq.infer();
392392
} catch (const Exception& e) {
393-
ORT_THROW(log_tag + " Couldn't start Inference: " + e.what());
393+
throw std::runtime_error(log_tag + " Couldn't start Inference: " + e.what());
394394
} catch (...) {
395-
ORT_THROW(log_tag + " In Error Couldn't start Inference");
395+
throw std::runtime_error(log_tag + " In Error Couldn't start Inference");
396396
}
397397
}
398398

399399
void OVInferRequest::WaitRequest() {
400400
try {
401401
ovInfReq.wait();
402402
} catch (const Exception& e) {
403-
ORT_THROW(log_tag + " Wait Model Failed: " + e.what());
403+
throw std::runtime_error(log_tag + " Wait Model Failed: " + e.what());
404404
} catch (...) {
405-
ORT_THROW(log_tag + " Wait Mode Failed");
405+
throw std::runtime_error(log_tag + " Wait Mode Failed");
406406
}
407407
}
408408

0 commit comments

Comments
 (0)