[ONNX FE] Fix ONNX DequantizeLinear-13 import dynamic shape (#16966)
This commit is contained in:
1 parent
d5123056bb
commit
2a5c69abc6
5 files changed
+124
-40
No files matched your search
@@ -72,7 +72,7 @@ void validate_scale(const Output<ngraph::Node> scale, const Output<ngraph::Node>
|
||||
const auto& x_shape = x.get_partial_shape();
|
||||
const auto& x_dim_at_axis = x_shape[axis];
|
||||
|
||||
NGRAPH_CHECK(scale_dim.same_scheme(x_dim_at_axis),
|
||||
NGRAPH_CHECK(scale_dim.compatible(x_dim_at_axis),
|
||||
"The number of dequantization scale elements '",
|
||||
scale_dim,
|
||||
"' must match the input shape dimension '",
|
||||
@@ -92,7 +92,7 @@ void validate_zero_point(const Output<ngraph::Node> zero_point, const Output<ngr
|
||||
const auto& x_shape = x.get_partial_shape();
|
||||
const auto& x_dim_at_axis = x_shape[axis];
|
||||
|
||||
NGRAPH_CHECK(zero_point_dim.same_scheme(x_dim_at_axis),
|
||||
NGRAPH_CHECK(zero_point_dim.compatible(x_dim_at_axis),
|
||||
"The number of zero point elements '",
|
||||
zero_point_dim,
|
||||
"' must match the input shape dimension '",
|
||||
@@ -122,7 +122,7 @@ std::shared_ptr<ngraph::Node> reshape_input(const Output<ngraph::Node>& input,
|
||||
if (x_shape[axis].is_static()) {
|
||||
target_dims.push_back(x_shape[axis].get_length());
|
||||
} else {
|
||||
target_dims.push_back(0);
|
||||
target_dims.push_back(-1);
|
||||
}
|
||||
|
||||
for (int64_t i = axis + 1; i < x_shape.rank().get_length(); ++i) {
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
ir_version: 3
|
||||
producer_name: "OpenVINO ONNX FE"
|
||||
graph {
|
||||
node {
|
||||
input: "X"
|
||||
input: "scale"
|
||||
input: "zero_point"
|
||||
output: "Y"
|
||||
name: "node1"
|
||||
op_type: "DequantizeLinear"
|
||||
attribute {
|
||||
name: "axis"
|
||||
i: 1
|
||||
type: INT
|
||||
}
|
||||
}
|
||||
name: "test"
|
||||
input {
|
||||
name: "X"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 3
|
||||
shape {
|
||||
dim {
|
||||
dim_value: -1
|
||||
}
|
||||
dim {
|
||||
dim_value: -1
|
||||
}
|
||||
dim {
|
||||
dim_value: -1
|
||||
}
|
||||
dim {
|
||||
dim_value: -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
input {
|
||||
name: "scale"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
input {
|
||||
name: "zero_point"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 3
|
||||
shape {
|
||||
dim {
|
||||
dim_value: 3
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
output {
|
||||
name: "Y"
|
||||
type {
|
||||
tensor_type {
|
||||
elem_type: 1
|
||||
shape {
|
||||
dim {
|
||||
dim_value: -1
|
||||
}
|
||||
dim {
|
||||
dim_value: -1
|
||||
}
|
||||
dim {
|
||||
dim_value: -1
|
||||
}
|
||||
dim {
|
||||
dim_value: -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
opset_import {
|
||||
version: 13
|
||||
}
|
||||
@@ -269,6 +269,31 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_dequantize_linear_1d_zero_scale_int8) {
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_dequantize_linear_1d_zero_scale_int8_4d_dynamic) {
|
||||
auto function = onnx_import::import_onnx_model(file_util::path_join(CommonTestUtils::getExecutableDirectory(),
|
||||
SERIALIZED_ZOO,
|
||||
"onnx/dequantize_linear_4_dynamic.onnx"));
|
||||
|
||||
auto test_case = ngraph::test::TestCase(function, s_device);
|
||||
|
||||
// The `axis` sttribute is set to 1
|
||||
// The data input shape in the onnx model is {-1, -1, -1, -1}
|
||||
test_case.add_input(Shape{2, 3, 2, 4}, std::vector<int8_t>{7, 9, 10, 10, 5, 8, 9, 1, 8, 6, 7, 9, 10, 0, 7, 10, 8,
|
||||
2, 6, 0, 5, 9, 8, 1, 2, 7, 5, 3, 2, 4, 1, 3, 8, 7,
|
||||
4, 8, 10, 1, 5, 5, 7, 7, 0, 2, 4, 4, 0, 5}); // x
|
||||
test_case.add_input(std::vector<float>{1.0f, 10.0f, 7.0f}); // scale
|
||||
test_case.add_input(std::vector<int8_t>{10, 2, 1}); // zero_point
|
||||
|
||||
test_case.add_expected_output<float>(
|
||||
{2, 3, 2, 4},
|
||||
std::vector<float>{-3.0f, -1.0f, 0.0f, 0.0f, -5.0f, -2.0f, -1.0f, -9.0f, 60.0f, 40.0f, 50.0f, 70.0f,
|
||||
80.0f, -20.0f, 50.0f, 80.0f, 49.0f, 7.0f, 35.0f, -7.0f, 28.0f, 56.0f, 49.0f, 0.0f,
|
||||
-8.0f, -3.0f, -5.0f, -7.0f, -8.0f, -6.0f, -9.0f, -7.0f, 60.0f, 50.0f, 20.0f, 60.0f,
|
||||
80.0f, -10.0f, 30.0f, 30.0f, 42.0f, 42.0f, -7.0f, 7.0f, 21.0f, 21.0f, -7.0f, 28.0f});
|
||||
|
||||
test_case.run();
|
||||
}
|
||||
|
||||
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_dequantize_linear_1d_zero_scale_int8_4d) {
|
||||
auto function = onnx_import::import_onnx_model(file_util::path_join(CommonTestUtils::getExecutableDirectory(),
|
||||
SERIALIZED_ZOO,
|
||||
@@ -276,11 +301,11 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_dequantize_linear_1d_zero_scale_int8_4d)
|
||||
|
||||
auto test_case = ngraph::test::TestCase(function, s_device);
|
||||
|
||||
test_case.add_input(std::vector<uint8_t>{7, 9, 10, 10, 5, 8, 9, 1, 8, 6, 7, 9, 10, 0, 7, 10,
|
||||
8, 2, 6, 0, 5, 9, 8, 1, 2, 7, 5, 3, 2, 4, 1, 3,
|
||||
8, 7, 4, 8, 10, 1, 5, 5, 7, 7, 0, 2, 4, 4, 0, 5}); // x
|
||||
test_case.add_input(std::vector<float>{1.0f, 10.0f, 7.0f}); // scale
|
||||
test_case.add_input(std::vector<uint8_t>{10, 2, 1}); // zero_point
|
||||
test_case.add_input(std::vector<int8_t>{7, 9, 10, 10, 5, 8, 9, 1, 8, 6, 7, 9, 10, 0, 7, 10,
|
||||
8, 2, 6, 0, 5, 9, 8, 1, 2, 7, 5, 3, 2, 4, 1, 3,
|
||||
8, 7, 4, 8, 10, 1, 5, 5, 7, 7, 0, 2, 4, 4, 0, 5}); // x
|
||||
test_case.add_input(std::vector<float>{1.0f, 10.0f, 7.0f}); // scale
|
||||
test_case.add_input(std::vector<int8_t>{10, 2, 1}); // zero_point
|
||||
|
||||
test_case.add_expected_output<float>(
|
||||
{2, 3, 2, 4},
|
||||
|
||||
@@ -10,20 +10,6 @@
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
# Quantize layer input 'Multiply_7' doesn't have blobs
|
||||
onnx_model_quantize_linear
|
||||
onnx_model_quantize_linear_zero_point
|
||||
onnx_model_quantize_linear_axis_zero
|
||||
onnx_model_quantize_linear_axis_negative
|
||||
onnx_expand_function
|
||||
|
||||
# DequantizeLinear:
|
||||
# C++ exception with description "Unsupported precisions!
|
||||
IE_CPU.onnx_model_dequantize_linear_scalar_zero_scale_int8
|
||||
IE_CPU.onnx_model_dequantize_linear_1d_zero_scale_int8
|
||||
# C++ exception with description "Input data precision not supported. Expected float.
|
||||
IE_CPU.onnx_model_dequantize_linear_1d_zero_scale_int8_4d
|
||||
|
||||
|
||||
# Result mismatch
|
||||
onnx_model_shape
|
||||
@@ -101,10 +87,6 @@ onnx_model_erf_int32
|
||||
# Could not eliminate all Dyn nodes
|
||||
onnx_model_conv_with_dynamic_batch
|
||||
|
||||
# Segmentation fault
|
||||
onnx_model_fake_quantize_nonconst_inputs_infer
|
||||
onnx_model_quantize_linear_const_scale_const_zero_p
|
||||
|
||||
# OneHot operation has a form that is not supported
|
||||
onnx_model_one_hot_without_axis
|
||||
onnx_model_one_hot_with_axis
|
||||
@@ -433,4 +415,3 @@ IE_CPU.onnx_model_top_k_repeating_unsorted
|
||||
|
||||
# Accuracy regression - Ticket 105909
|
||||
IE_CPU.onnx_model_attention_qkv_hidden_sizes
|
||||
|
||||
@@ -12,19 +12,6 @@ INTERPRETER.onnx_dyn_shapes_expand_uint16_dyn_shape
|
||||
|
||||
# Revise reference implementation
|
||||
onnx_dyn_model_hardmax
|
||||
onnx_model_quantize_linear_const_scale_const_zero_p
|
||||
onnx_model_quantize_linear
|
||||
onnx_model_quantize_linear_axis_zero
|
||||
onnx_model_quantize_linear_axis_negative
|
||||
|
||||
# Removed opset0 operations
|
||||
INTERPRETER.onnx_model_dequantize_linear
|
||||
INTERPRETER.onnx_model_dequantize_linear_scalar_zero_scale_uint8
|
||||
INTERPRETER.onnx_model_dequantize_linear_scalar_zero_scale_int8
|
||||
INTERPRETER.onnx_model_dequantize_linear_1d_zero_scale_uint8
|
||||
INTERPRETER.onnx_model_dequantize_linear_1d_zero_scale_int8
|
||||
INTERPRETER.onnx_model_dequantize_linear_1d_zero_scale_int8_4d
|
||||
INTERPRETER.onnx_model_dequantize_linear_1d_zero_scale_uint8_negative_axis
|
||||
|
||||
# ONNX evaluate method not implemented for If operator
|
||||
INTERPRETER.onnx_if_inside_if
|
||||
|
||||
Reference in new issue
Block a user