forked from microsoft/onnxruntime
-
Notifications
You must be signed in to change notification settings - Fork 45
Report import failure error code #715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
javier-intel
wants to merge
5
commits into
ovep-develop
Choose a base branch
from
jemartin/import_failure_error_code
base: ovep-develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8ad8b6e
Catch model import failure and report the appropriate error
javier-intel f99be53
Update onnxruntime/core/providers/openvino/openvino_execution_provide…
MayureshV1 64df737
Update onnxruntime/core/providers/openvino/exceptions.h
MayureshV1 bf3e495
Formatting and other minor changes
javier-intel 64bcdad
Code review fixes
javier-intel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright (C) Intel Corporation | ||
// Licensed under the MIT License | ||
|
||
#pragma once | ||
|
||
#include <exception> | ||
#include <regex> | ||
#include <string> | ||
|
||
#include "core/common/status.h" | ||
|
||
namespace onnxruntime { | ||
namespace openvino_ep { | ||
|
||
struct ovep_exception : public std::exception { | ||
enum class type { | ||
compile_model, | ||
import_model, | ||
query_prop, | ||
read_model, | ||
unknown, | ||
}; | ||
|
||
ovep_exception(const std::string& message, | ||
enum class type type) : message_{message}, | ||
type_{type}, | ||
error_code_{ze_result_code_from_string(message)}, | ||
error_name_{ze_result_name_from_string(message)} {} | ||
|
||
const char* what() const noexcept override { | ||
return message_.data(); | ||
} | ||
|
||
uint32_t get_code() const { return error_code_; } | ||
MayureshV1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
operator common::Status() const { | ||
common::StatusCategory category_ort{common::ONNXRUNTIME}; | ||
|
||
if (type_ == type::unknown) { | ||
return {category_ort, common::FAIL, message_}; | ||
} | ||
|
||
// Newer drivers | ||
if ((type_ == type::import_model) && | ||
(error_code_ == 0x7800000f /* ZE_RESULT_ERROR_INVALID_NATIVE_BINARY */)) { | ||
javier-intel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
std::string message{error_name_ + ", code 0x" + std::to_string(error_code_) + "\nModel needs to be recompiled\n"}; | ||
return {category_ort, common::INVALID_GRAPH, message}; | ||
} | ||
|
||
std::string error_message = "Unhandled exception type: " + std::to_string(static_cast<int>(type_)); | ||
return {category_ort, common::FAIL, error_message}; | ||
} | ||
|
||
protected: | ||
std::string message_; | ||
type type_{type::unknown}; | ||
uint32_t error_code_{0}; | ||
std::string error_name_; | ||
|
||
private: | ||
uint32_t ze_result_code_from_string(const std::string& ov_exception_string) { | ||
uint32_t error_code{0}; | ||
std::regex error_code_pattern("code 0x([0-9a-fA-F]+)"); | ||
std::smatch matches; | ||
if (std::regex_search(ov_exception_string, matches, error_code_pattern)) { | ||
std::from_chars(&(*matches[1].first), &(*matches[1].second), error_code, 16); | ||
} | ||
return error_code; | ||
} | ||
std::string ze_result_name_from_string(const std::string& ov_exception_string) { | ||
std::string error_message = "UNKNOWN NPU ERROR"; | ||
std::regex error_message_pattern(R"(\bZE_\w*\b)"); | ||
std::smatch matches; | ||
if (std::regex_search(ov_exception_string, matches, error_message_pattern)) { | ||
error_message = matches[0]; | ||
} | ||
return error_message; | ||
} | ||
}; | ||
|
||
} // namespace openvino_ep | ||
} // namespace onnxruntime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.