Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions onnxruntime/core/providers/openvino/openvino_execution_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string>
#include <memory>
#include <vector>
#include <charconv>
#include "core/providers/shared_library/provider_api.h"
#include "core/providers/openvino/openvino_execution_provider.h"
#include "core/providers/openvino/contexts.h"
Expand Down Expand Up @@ -170,12 +171,19 @@
return 0;
};

compute_info.compute_func = [](FunctionState state, const OrtApi* /* api */, OrtKernelContext* context) {
compute_info.compute_func = [](FunctionState state, const OrtApi* /* api */, OrtKernelContext* context) -> Status {
auto function_state = static_cast<OpenVINOEPFunctionState*>(state);
try {
function_state->backend_manager.Compute(context);
} catch (const std::exception& ex) {
return common::Status(common::ONNXRUNTIME, common::FAIL, ex.what());
// Extract error code from message with pattern: "<code>|message"
auto get_error_code = [](std::string_view msg) {
if (auto pos = msg.find('|'); pos != std::string_view::npos)

Check notice on line 181 in onnxruntime/core/providers/openvino/openvino_execution_provider.cc

View workflow job for this annotation

GitHub Actions / cpplint

[cpplint] onnxruntime/core/providers/openvino/openvino_execution_provider.cc#L181

If/else bodies with multiple statements require braces [readability/braces] [4]
Raw output
onnxruntime/core/providers/openvino/openvino_execution_provider.cc:181:  If/else bodies with multiple statements require braces  [readability/braces] [4]
if (int code = 0; std::from_chars(msg.data(), msg.data() + pos, code).ec == std::errc{})
return code;
return static_cast<int>(common::EP_FAIL);
};
return common::Status(common::ONNXRUNTIME, get_error_code(ex.what()), ex.what());
}
return Status::OK();
};
Expand Down
18 changes: 15 additions & 3 deletions onnxruntime/core/providers/openvino/ov_interface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,23 @@ namespace openvino_ep {

template <typename Func, typename... Args>
inline auto OvExceptionBoundary(Func&& func, std::format_string<Args...>&& fmt, Args&&... args) {
return OvExceptionBoundary(func, ORT_EP_FAIL, std::forward<std::format_string<Args...>>(fmt), std::forward<Args>(args)...);
}

template <typename Func, typename... Args>
inline auto OvExceptionBoundary(Func&& func, OrtErrorCode error_code, std::format_string<Args...>&& fmt, Args&&... args) {
try {
return func();
} catch (const ov::Exception& e) {
ORT_THROW(log_tag + std::vformat(fmt.get(), std::make_format_args(args...)) + ": " + std::string(e.what()));
// Encode error code as prefix: "<code>|message"
auto msg = std::format("{}|{}{}: {}", static_cast<int>(error_code), log_tag,
std::vformat(fmt.get(), std::make_format_args(args...)), e.what());
ORT_THROW(msg);
} catch (...) {
ORT_THROW(log_tag + std::vformat(fmt.get(), std::make_format_args(args...)));
// Encode error code as prefix: "<code>|message"
auto msg = std::format("{}|{}{}", static_cast<int>(error_code), log_tag,
std::vformat(fmt.get(), std::make_format_args(args...)));
ORT_THROW(msg);
}
}

Expand Down Expand Up @@ -214,7 +225,8 @@ OVExeNetwork OVCore::ImportModel(ModelBlobWrapper& model_blob,
#endif
return exe;
},
"Exception while Loading Network for graph {}", name);
ORT_INVALID_GRAPH,
"Exception while importing model for graph {}", name);
}

OVExeNetwork OVCore::ImportEPCtxOVIREncapsulation(std::istream& model_stream,
Expand Down
Loading