Skip to content
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

Fix reading of onnx domain causing one of the automl models to break in 0.5 release. #1694

Merged
merged 17 commits into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
b03dc6f
Mention OrtCreateSessionFromArray in C API doc
pranavsharma Jul 22, 2019
cc5b316
Merge branch 'master' of https://github.com/Microsoft/onnxruntime
pranavsharma Jul 23, 2019
4ef6284
Merge branch 'master' of https://github.com/Microsoft/onnxruntime
pranavsharma Jul 25, 2019
85bd0dc
Merge branch 'master' of https://github.com/Microsoft/onnxruntime
pranavsharma Jul 25, 2019
42aa76c
Merge branch 'master' of https://github.com/Microsoft/onnxruntime
pranavsharma Jul 31, 2019
27ac7f1
Merge branch 'master' of https://github.com/Microsoft/onnxruntime
pranavsharma Aug 7, 2019
8fdbd2e
Merge branch 'master' of https://github.com/Microsoft/onnxruntime
pranavsharma Aug 8, 2019
704934b
Merge branch 'master' of https://github.com/Microsoft/onnxruntime
pranavsharma Aug 13, 2019
10f46b4
Merge branch 'master' of https://github.com/Microsoft/onnxruntime
pranavsharma Aug 14, 2019
3c64f87
Merge branch 'master' of https://github.com/Microsoft/onnxruntime
pranavsharma Aug 15, 2019
d4d3008
Merge branch 'master' of https://github.com/Microsoft/onnxruntime
pranavsharma Aug 16, 2019
d06cfbd
Merge branch 'master' of https://github.com/Microsoft/onnxruntime
pranavsharma Aug 17, 2019
946be7a
Merge branch 'master' of https://github.com/Microsoft/onnxruntime
pranavsharma Aug 19, 2019
0553e07
Merge branch 'master' of https://github.com/Microsoft/onnxruntime
pranavsharma Aug 24, 2019
d2dc35b
Fix registration of Equal op causing one of the automl models to brea…
pranavsharma Aug 26, 2019
586434f
Merge remote-tracking branch 'origin/master' into fix_equal_op_regist…
pranavsharma Aug 29, 2019
a08eba2
updates...
pranavsharma Aug 29, 2019
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
13 changes: 10 additions & 3 deletions onnxruntime/core/graph/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,25 @@ Model::Model(std::unique_ptr<ModelProto> model_proto, const IOnnxRuntimeOpSchema
const auto& domain = opSet.domain();
const auto version = opSet.version();
// empty domain and 'ai.onnx' are equivalent
if ((domain.empty() || domain == "ai.onnx") && version < 7) {
if ((domain.empty() || domain == kOnnxDomainAlias) && version < 7) {
// TODO: Check if we can upgrade all the current opset 6 models that are being tested
// in CI to opset 7 or above
LOGS_DEFAULT(WARNING) << "ONNX Runtime only *guarantees* support for models stamped "
"with opset version 7 or above for opset domain 'ai.onnx'. "
"Please upgrade your model to opset 7 or higher. "
"For now, this opset "
<< version
<< version
<< " model may run depending upon legacy support "
"of some older opset version operators.";
}
domain_to_version[domain] = gsl::narrow_cast<int>(version);
// We need to overwrite the domain here with ("") or else the loop below will try to find ("")
// in the map and if not found (when domain == kOnnxDomainAlias), adds an entry for ("", 11).
// This effectively ignores the opset version specified by the model for the onnx domain.
if (domain == kOnnxDomainAlias) {
domain_to_version[kOnnxDomain] = gsl::narrow_cast<int>(version);
} else {
domain_to_version[domain] = gsl::narrow_cast<int>(version);
}
}

auto domain_map = schema_registry->GetLatestOpsetVersions(false);
Expand Down
17 changes: 14 additions & 3 deletions onnxruntime/test/framework/inference_session_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class FuseExecutionProvider : public IExecutionProvider {
class InferenceSessionGetGraphWrapper : public InferenceSession {
public:
explicit InferenceSessionGetGraphWrapper(const SessionOptions& session_options,
logging::LoggingManager* logging_manager) : InferenceSession(session_options, logging_manager) {
logging::LoggingManager* logging_manager) : InferenceSession(session_options, logging_manager) {
}

const Graph& GetGraph() {
Expand Down Expand Up @@ -364,7 +364,7 @@ TEST(InferenceSessionTests, TestModelSerialization) {
InferenceSessionGetGraphWrapper session_object{so, &DefaultLoggingManager()};
ASSERT_TRUE(session_object.Load(test_model).IsOK());
ASSERT_TRUE(session_object.Initialize().IsOK());

// Assert that model has been transformed and identity Node is removed.
const auto& graph = session_object.GetGraph();
std::map<std::string, int> op_to_count = CountOpsInGraph(graph);
Expand All @@ -383,7 +383,7 @@ TEST(InferenceSessionTests, TestModelSerialization) {
InferenceSession session_object_opt{so_opt, &DefaultLoggingManager()};
ASSERT_TRUE(session_object_opt.Load(so.optimized_model_filepath).IsOK());
ASSERT_TRUE(session_object_opt.Initialize().IsOK());

// Assert that re-feed of optimized model with default transform level results
// in same runtime model as abs-id-max.onnx with TransformLevel-1.
std::ifstream model_fs_session1(so.optimized_model_filepath, ios::in | ios::binary);
Expand Down Expand Up @@ -1481,5 +1481,16 @@ TEST(InferenceSessionTests, TestParallelExecutionWithCudaProvider) {

#endif

TEST(InferenceSessionTests, ModelWithKOnnxDomainAlias) {
SessionOptions so;
so.session_logid = "InferenceSessionTests.NoTimeout";
InferenceSession session_object{so, &DefaultLoggingManager()};
std::string file_name = "testdata/test_model_with_fullonnxdomain.onnx";
auto ret_status = session_object.Load(file_name);
ASSERT_TRUE(ret_status.IsOK()) << ret_status.ErrorMessage();
ret_status = session_object.Initialize();
ASSERT_TRUE(ret_status.IsOK()) << ret_status.ErrorMessage();
}

} // namespace test
} // namespace onnxruntime
18 changes: 18 additions & 0 deletions onnxruntime/test/testdata/test_model_with_fullonnxdomain.onnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
 onnx-example"ai.onnx:j

X1
X2Y"Equal:ai.onnx
test-modelZ
X1


Z
X2


b
Y
 

B
ai.onnx