[Model Enablement] fix default onnx domain (#10106)

This commit is contained in:
Bartek Szmelczynski 2022-02-10 01:16:24 +01:00 committed by GitHub
parent 87c6e09cae
commit 36de4e8e28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 372 additions and 0 deletions

View File

@ -0,0 +1,60 @@
ir_version: 3
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "X"
output: "Y"
op_type: "Unsqueeze"
attribute {
name: "axes"
ints: 0
type: INTS
}
}
name: "test-model-unsqueeze"
input {
name: "X"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 3
}
dim {
dim_value: 4
}
dim {
dim_value: 5
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 1
}
dim {
dim_value: 3
}
dim {
dim_value: 4
}
dim {
dim_value: 5
}
}
}
}
}
}
opset_import {
version: 7
domain: "ai.onnx"
}

View File

@ -0,0 +1,84 @@
ir_version: 8
producer_name: "onnx-importer-test"
graph {
node {
output: "AXIS"
op_type: "Constant"
attribute {
name: "value"
t {
dims: 1
data_type: 6
int32_data: 0
name: "const_tensor"
}
type: TENSOR
}
}
node {
input: "X"
input: "AXIS"
output: "Y"
op_type: "Unsqueeze"
}
name: "test-model-unsqueeze"
input {
name: "X"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 3
}
dim {
dim_value: 4
}
dim {
dim_value: 5
}
}
}
}
}
input {
name: "AXIS"
type {
tensor_type {
elem_type: 6
shape {
dim {
dim_value: 1
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 1
}
dim {
dim_value: 3
}
dim {
dim_value: 4
}
dim {
dim_value: 5
}
}
}
}
}
}
opset_import {
domain: "ai.onnx"
version: 13
}

View File

@ -0,0 +1,59 @@
ir_version: 3
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "X"
output: "Y"
op_type: "Unsqueeze"
attribute {
name: "axes"
ints: 0
type: INTS
}
}
name: "test-model-unsqueeze"
input {
name: "X"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 3
}
dim {
dim_value: 4
}
dim {
dim_value: 5
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 1
}
dim {
dim_value: 3
}
dim {
dim_value: 4
}
dim {
dim_value: 5
}
}
}
}
}
}
opset_import {
version: 7
}

View File

@ -0,0 +1,84 @@
ir_version: 8
producer_name: "onnx-importer-test"
graph {
node {
output: "AXIS"
op_type: "Constant"
attribute {
name: "value"
t {
dims: 1
data_type: 6
int32_data: 0
name: "const_tensor"
}
type: TENSOR
}
}
node {
input: "X"
input: "AXIS"
output: "Y"
op_type: "Unsqueeze"
}
name: "test-model-unsqueeze"
input {
name: "X"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 3
}
dim {
dim_value: 4
}
dim {
dim_value: 5
}
}
}
}
}
input {
name: "AXIS"
type {
tensor_type {
elem_type: 6
shape {
dim {
dim_value: 1
}
}
}
}
}
output {
name: "Y"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 1
}
dim {
dim_value: 3
}
dim {
dim_value: 4
}
dim {
dim_value: 5
}
}
}
}
}
}
opset_import {
domain: ""
version: 13
}

View File

@ -4654,3 +4654,85 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_aten_unsupported_operator) {
FAIL() << "Other exception than expected was thrown.";
}
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_unsqueeze_ai_onnx_domain) {
auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/unsqueeze_ai_onnx_domain.onnx"));
auto input = test::NDArray<float, 3>({{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}})
.get_vector();
auto expected_output =
test::NDArray<float, 4>({{{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}}})
.get_vector();
auto test_case = test::TestCase(function, s_device);
test_case.add_input(input);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_unsqueeze_default_domain) {
auto function =
onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/unsqueeze_default_domain.onnx"));
auto input = test::NDArray<float, 3>({{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}})
.get_vector();
auto expected_output =
test::NDArray<float, 4>({{{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}}})
.get_vector();
auto test_case = test::TestCase(function, s_device);
test_case.add_input(input);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_unsqueeze_default_domain_opset13) {
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/unsqueeze_default_domain_opset13.onnx"));
auto input = test::NDArray<float, 3>({{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}})
.get_vector();
auto expected_output =
test::NDArray<float, 4>({{{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}}})
.get_vector();
auto test_case = test::TestCase(function, s_device);
test_case.add_input(input);
test_case.add_expected_output(expected_output);
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_unsqueeze_ai_onnx_domain_opset13) {
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/unsqueeze_ai_onnx_domain_opset13.onnx"));
auto input = test::NDArray<float, 3>({{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}})
.get_vector();
auto expected_output =
test::NDArray<float, 4>({{{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}},
{{1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}, {1, 1, 1, 1, 1}}}})
.get_vector();
auto test_case = test::TestCase(function, s_device);
test_case.add_input(input);
test_case.add_expected_output(expected_output);
test_case.run();
}

View File

@ -32,6 +32,9 @@ Model::Model(std::shared_ptr<ONNX_NAMESPACE::ModelProto> model_proto) : m_model_
// unknown or invalid.
for (const auto& id : m_model_proto->opset_import()) {
auto domain = id.has_domain() ? id.domain() : "";
if (domain == "ai.onnx") {
domain = "";
}
m_opset.emplace(domain, OperatorsBridge::get_operator_set(domain, id.version()));
}
// onnx.proto(.3): the empty string ("") for domain or absence of opset_import field