diff --git a/ngraph/frontend/onnx/frontend/CMakeLists.txt b/ngraph/frontend/onnx/frontend/CMakeLists.txt index 43c3e4b362e..e6f15499a33 100644 --- a/ngraph/frontend/onnx/frontend/CMakeLists.txt +++ b/ngraph/frontend/onnx/frontend/CMakeLists.txt @@ -13,11 +13,9 @@ file(GLOB_RECURSE LIBRARY_PUBLIC_HEADERS ${ONNX_FRONTEND_INCLUDE_DIR}/*.hpp) # Remove disabled ops list(REMOVE_ITEM LIBRARY_SRC - ${CMAKE_CURRENT_SOURCE_DIR}/src/op/conv_integer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/op/quant_conv.cpp ) list(REMOVE_ITEM LIBRARY_HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/src/op/conv_integer.hpp ${CMAKE_CURRENT_SOURCE_DIR}/src/op/quant_conv.hpp ) diff --git a/ngraph/frontend/onnx/frontend/src/op/conv.cpp b/ngraph/frontend/onnx/frontend/src/op/conv.cpp index 230ae916bc7..1e2561ce014 100644 --- a/ngraph/frontend/onnx/frontend/src/op/conv.cpp +++ b/ngraph/frontend/onnx/frontend/src/op/conv.cpp @@ -14,6 +14,7 @@ #include "ngraph/op/group_conv.hpp" #include "ngraph/op/util/attr_types.hpp" #include "onnx_import/core/null_node.hpp" +#include "utils/conv_factory.hpp" #include "utils/convpool.hpp" #include "utils/reshape.hpp" @@ -22,34 +23,6 @@ namespace onnx_import { namespace op { namespace set_1 { namespace detail { -std::shared_ptr make_ng_convolution(const Output& data, - const Output& filters, - const ngraph::Strides& strides, - const ngraph::Strides& dilations, - const ngraph::CoordinateDiff& padding_below, - const ngraph::CoordinateDiff& padding_above, - int64_t groups, - const ngraph::op::PadType& auto_pad) { - if (groups > 1) { - const auto reshaped_filters = convpool::get_reshaped_filters(filters, groups); - - return std::make_shared(data, - reshaped_filters, - strides, - padding_below, - padding_above, - dilations, - auto_pad); - } else { - return std::make_shared(data, - filters, - strides, - padding_below, - padding_above, - dilations, - auto_pad); - } -} std::shared_ptr add_bias(const Output& ng_conv, const Output& bias) { const auto conv_shape = std::make_shared(ng_conv); @@ -76,8 +49,14 @@ OutputVector conv(const Node& node, const auto& padding_below = paddings.first; const auto& padding_above = paddings.second; - const auto conv_node = - make_ng_convolution(data, filters, strides, dilations, padding_below, padding_above, groups, auto_pad_type); + const auto conv_node = conv_factory::make_ng_convolution(data, + filters, + strides, + dilations, + padding_below, + padding_above, + groups, + auto_pad_type); // no bias param if (ngraph::op::is_null(bias)) { diff --git a/ngraph/frontend/onnx/frontend/src/op/conv_integer.cpp b/ngraph/frontend/onnx/frontend/src/op/conv_integer.cpp index bfe245fb623..a93dc90b2f7 100644 --- a/ngraph/frontend/onnx/frontend/src/op/conv_integer.cpp +++ b/ngraph/frontend/onnx/frontend/src/op/conv_integer.cpp @@ -2,111 +2,67 @@ // SPDX-License-Identifier: Apache-2.0 // -// Disabled in CMakeList -// Update to higher opset required - #include "op/conv_integer.hpp" -#include "exceptions.hpp" -#include "ngraph/builder/make_constant.hpp" -#include "ngraph/op/util/attr_types.hpp" -#include "ngraph/opsets/opset0.hpp" + +#include "default_opset.hpp" +#include "utils/conv_factory.hpp" #include "utils/convpool.hpp" +#include "utils/reshape.hpp" -using namespace ngraph::builder; +namespace ngraph { +namespace onnx_import { +namespace op { +namespace set_1 { -namespace ngraph -{ - namespace onnx_import - { - namespace op - { - namespace set_1 - { - OutputVector conv_integer(const Node& node) - { - const OutputVector& inputs = node.get_ng_inputs(); - auto num_inputs = inputs.size(); - auto input = inputs.at(0); - auto filters = inputs.at(1); +OutputVector conv_integer(const Node& node) { + const OutputVector& inputs = node.get_ng_inputs(); - int64_t groups{node.get_attribute_value("group", 1)}; - CHECK_VALID_NODE( - node, - groups == 1, - "Only value of 1 for 'group' supported for ConvInteger. Given: ", - groups); + const auto& input = inputs.at(0); + const auto& filter = inputs.at(1); + const auto& input_zero_point = + (inputs.size() > 2) ? inputs.at(2) : ngraph::op::Constant::create(ngraph::element::i32, {1}, {0}); + const auto& filter_zero_point = + (inputs.size() > 3) ? inputs.at(3) : ngraph::op::Constant::create(ngraph::element::i32, {1}, {0}); - auto window_movement_strides = convpool::get_strides(node); - auto window_dilation_strides = convpool::get_dilations(node); - auto paddings = convpool::get_pads(node); - ngraph::op::PadType auto_pad_type = convpool::get_auto_pad(node); - auto& padding_below = paddings.first; - auto& padding_above = paddings.second; - convpool::calculate_auto_pads(input.get_shape(), - filters.get_shape(), - window_movement_strides, - window_dilation_strides, - auto_pad_type, - padding_below, - padding_above); + const auto& converted_input = std::make_shared(input, element::i32); + const auto& converted_filter = std::make_shared(filter, element::i32); - const Strides default_data_dilation_strides(input.get_shape().size() - 2, 1); - auto scale_one = make_constant(ngraph::element::f32, Shape{}, 1); - auto input_zero_point = make_constant(input.get_element_type(), Shape{}, 0); - auto filters_zero_point = make_constant(filters.get_element_type(), Shape{}, 0); - auto output_zero_point = make_constant(ngraph::element::i32, Shape{}, 0); + const auto& converted_input_zero_point = std::make_shared(input_zero_point, element::i32); + const auto& converted_filter_zero_point = std::make_shared(filter_zero_point, element::i32); - if (num_inputs == 2) - { - return {std::make_shared( - input, - filters, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - default_data_dilation_strides, - scale_one, - input_zero_point, - scale_one, - filters_zero_point, - scale_one, - output_zero_point, - ngraph::element::i32, - ngraph::AxisSet{}, - ngraph::AxisSet{}, - ngraph::AxisSet{})}; - } + const auto& input_shape = std::make_shared(input, element::i32); + const auto& input_rank = std::make_shared(input_shape, element::i32); + const auto& input_rank_scalar = reshape::interpret_as_scalar(input_rank); - input_zero_point = inputs.at(2); - if (num_inputs == 4) - { - filters_zero_point = inputs.at(3); - } + const auto& one_node = ngraph::op::Constant::create(ngraph::element::i32, {}, {1}); + const auto& missing_dimensions = + std::make_shared(one_node, input_rank_scalar, one_node, element::i32); + const auto& resized_filter_zero_point = + std::make_shared(converted_filter_zero_point, missing_dimensions); - return {std::make_shared( - input, - filters, - window_movement_strides, - window_dilation_strides, - padding_below, - padding_above, - default_data_dilation_strides, - scale_one, - input_zero_point, - scale_one, - filters_zero_point, - scale_one, - output_zero_point, - ngraph::element::i32, - ngraph::AxisSet{}, - ngraph::AxisSet{}, - ngraph::AxisSet{})}; - } - } // namespace set_1 + const auto& shifted_input = std::make_shared(converted_input, converted_input_zero_point); + const auto& shifted_filter = std::make_shared(converted_filter, resized_filter_zero_point); - } // namespace op + const auto& groups = node.get_attribute_value("group", 1); + const auto& strides = convpool::get_strides(node); + const auto& dilations = convpool::get_dilations(node); + const auto& paddings = convpool::get_pads(node); + const ngraph::op::PadType& auto_pad_type = convpool::get_auto_pad(node); + const auto& padding_below = paddings.first; + const auto& padding_above = paddings.second; - } // namespace onnx_import + const auto conv_node = conv_factory::make_ng_convolution(shifted_input, + shifted_filter, + strides, + dilations, + padding_below, + padding_above, + groups, + auto_pad_type); -} // namespace ngraph + return {conv_node}; +} +} // namespace set_1 +} // namespace op +} // namespace onnx_import +} // namespace ngraph diff --git a/ngraph/frontend/onnx/frontend/src/op/conv_integer.hpp b/ngraph/frontend/onnx/frontend/src/op/conv_integer.hpp index 8725c93accd..7be21b41a4f 100644 --- a/ngraph/frontend/onnx/frontend/src/op/conv_integer.hpp +++ b/ngraph/frontend/onnx/frontend/src/op/conv_integer.hpp @@ -2,34 +2,27 @@ // SPDX-License-Identifier: Apache-2.0 // -// Disabled in CMakeList -// Update to higher opset required - #pragma once #include "ngraph/node.hpp" #include "onnx_import/core/node.hpp" -namespace ngraph -{ - namespace onnx_import - { - namespace op - { - namespace set_1 - { - /// \brief Performs ONNX ConvInteger operation. - /// - /// \param node The ONNX node object representing this operation. - /// - /// \return The vector containing Ngraph nodes producing output of quantized ONNX - /// convolution operation. - OutputVector conv_integer(const Node& node); +namespace ngraph { +namespace onnx_import { +namespace op { +namespace set_1 { +/// \brief Performs ONNX ConvInteger operation. +/// +/// \param node The ONNX node object representing this operation. +/// +/// \return The vector containing Ngraph nodes producing output of quantized ONNX +/// convolution operation. +OutputVector conv_integer(const Node& node); - } // namespace set_1 +} // namespace set_1 - } // namespace op +} // namespace op - } // namespace onnx_import +} // namespace onnx_import -} // namespace ngraph +} // namespace ngraph diff --git a/ngraph/frontend/onnx/frontend/src/ops_bridge.cpp b/ngraph/frontend/onnx/frontend/src/ops_bridge.cpp index 768db860144..3c8e0594e32 100644 --- a/ngraph/frontend/onnx/frontend/src/ops_bridge.cpp +++ b/ngraph/frontend/onnx/frontend/src/ops_bridge.cpp @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 // +#include "ops_bridge.hpp" + #include #include #include @@ -38,7 +40,7 @@ #include "op/constant_fill.hpp" #include "op/constant_of_shape.hpp" #include "op/conv.hpp" -// #include "op/conv_integer.hpp" +#include "op/conv_integer.hpp" #include "op/conv_transpose.hpp" #include "op/cos.hpp" #include "op/cosh.hpp" @@ -156,7 +158,6 @@ #include "op/upsample.hpp" #include "op/where.hpp" #include "op/xor.hpp" -#include "ops_bridge.hpp" namespace ngraph { namespace onnx_import { @@ -304,7 +305,7 @@ OperatorsBridge::OperatorsBridge() { REGISTER_OPERATOR("Constant", 13, constant); REGISTER_OPERATOR("ConstantOfShape", 1, constant_of_shape); REGISTER_OPERATOR("Conv", 1, conv); - // REGISTER_OPERATOR("ConvInteger", 1, conv_integer); + REGISTER_OPERATOR("ConvInteger", 1, conv_integer); REGISTER_OPERATOR("ConvTranspose", 1, conv_transpose); REGISTER_OPERATOR("Compress", 1, compress); REGISTER_OPERATOR("Cos", 1, cos); diff --git a/ngraph/frontend/onnx/frontend/src/utils/conv_factory.cpp b/ngraph/frontend/onnx/frontend/src/utils/conv_factory.cpp new file mode 100644 index 00000000000..a09e291a299 --- /dev/null +++ b/ngraph/frontend/onnx/frontend/src/utils/conv_factory.cpp @@ -0,0 +1,50 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "utils/conv_factory.hpp" + +#include "default_opset.hpp" +#include "exceptions.hpp" +#include "ngraph/builder/reshape.hpp" +#include "ngraph/op/group_conv.hpp" +#include "ngraph/op/util/attr_types.hpp" +#include "onnx_import/core/null_node.hpp" +#include "utils/conv_factory.hpp" +#include "utils/convpool.hpp" +#include "utils/reshape.hpp" + +namespace ngraph { +namespace onnx_import { +namespace conv_factory { +std::shared_ptr make_ng_convolution(const Output& data, + const Output& filters, + const ngraph::Strides& strides, + const ngraph::Strides& dilations, + const ngraph::CoordinateDiff& padding_below, + const ngraph::CoordinateDiff& padding_above, + int64_t groups, + const ngraph::op::PadType& auto_pad) { + if (groups > 1) { + const auto reshaped_filters = convpool::get_reshaped_filters(filters, groups); + + return std::make_shared(data, + reshaped_filters, + strides, + padding_below, + padding_above, + dilations, + auto_pad); + } else { + return std::make_shared(data, + filters, + strides, + padding_below, + padding_above, + dilations, + auto_pad); + } +} +} // namespace conv_factory +} // namespace onnx_import +} // namespace ngraph diff --git a/ngraph/frontend/onnx/frontend/src/utils/conv_factory.hpp b/ngraph/frontend/onnx/frontend/src/utils/conv_factory.hpp new file mode 100644 index 00000000000..fc1ef42abf5 --- /dev/null +++ b/ngraph/frontend/onnx/frontend/src/utils/conv_factory.hpp @@ -0,0 +1,24 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "ngraph/node.hpp" +#include "ngraph/op/op.hpp" +#include "onnx_import/core/node.hpp" + +namespace ngraph { +namespace onnx_import { +namespace conv_factory { +std::shared_ptr make_ng_convolution(const Output& data, + const Output& filters, + const ngraph::Strides& strides, + const ngraph::Strides& dilations, + const ngraph::CoordinateDiff& padding_below, + const ngraph::CoordinateDiff& padding_above, + int64_t groups, + const ngraph::op::PadType& auto_pad); +} // namespace conv_factory +} // namespace onnx_import +} // namespace ngraph diff --git a/ngraph/test/models/onnx/conv_integer.prototxt b/ngraph/test/models/onnx/conv_integer.prototxt index e677f64e0ab..59eaa27b097 100644 --- a/ngraph/test/models/onnx/conv_integer.prototxt +++ b/ngraph/test/models/onnx/conv_integer.prototxt @@ -1,27 +1,15 @@ -ir_version: 5 +ir_version: 7 producer_name: "nGraph ONNX Importer" graph { node { input: "x" input: "w" input: "x_zero_point" + input: "w_zero_point" output: "y" - name: "node1" op_type: "ConvInteger" - attribute { - name: "group" - i: 1 - type: INT - } - attribute { - name: "auto_pad" - s: "NOTSET" - type: STRING - } - doc_string: "ConvInteger" - domain: "" } - name: "test" + name: "ConvInt" input { name: "x" type { @@ -72,6 +60,22 @@ graph { tensor_type { elem_type: 2 shape { + dim { + dim_value: 1 + } + } + } + } + } + input { + name: "w_zero_point" + type { + tensor_type { + elem_type: 2 + shape { + dim { + dim_value: 1 + } } } } diff --git a/ngraph/test/models/onnx/conv_integer_int8.prototxt b/ngraph/test/models/onnx/conv_integer_int8.prototxt new file mode 100644 index 00000000000..b0d9340f0d1 --- /dev/null +++ b/ngraph/test/models/onnx/conv_integer_int8.prototxt @@ -0,0 +1,109 @@ +ir_version: 7 +producer_name: "backend-test" +graph { + node { + input: "x" + input: "w" + input: "x_zero_point" + input: "w_zero_point" + output: "y" + op_type: "ConvInteger" + } + name: "ConvInt" + input { + name: "x" + type { + tensor_type { + elem_type: 3 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 3 + } + dim { + dim_value: 3 + } + } + } + } + } + input { + name: "w" + type { + tensor_type { + elem_type: 3 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "x_zero_point" + type { + tensor_type { + elem_type: 3 + shape { + dim { + dim_value: 1 + } + } + } + } + } + input { + name: "w_zero_point" + type { + tensor_type { + elem_type: 3 + shape { + dim { + dim_value: 1 + } + } + } + } + } + output { + name: "y" + type { + tensor_type { + elem_type: 6 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + domain: "" + version: 10 +} diff --git a/ngraph/test/models/onnx/conv_integer_no_zero_point.prototxt b/ngraph/test/models/onnx/conv_integer_no_zero_point.prototxt index 35557de631c..c2f0ce533a8 100644 --- a/ngraph/test/models/onnx/conv_integer_no_zero_point.prototxt +++ b/ngraph/test/models/onnx/conv_integer_no_zero_point.prototxt @@ -1,31 +1,18 @@ -ir_version: 5 +ir_version: 7 producer_name: "nGraph ONNX Importer" graph { node { input: "x" input: "w" output: "y" - name: "node1" op_type: "ConvInteger" - attribute { - name: "group" - i: 1 - type: INT - } - attribute { - name: "auto_pad" - s: "NOTSET" - type: STRING - } - doc_string: "ConvInteger" - domain: "" } - name: "test" + name: "ConvInt" input { name: "x" type { tensor_type { - elem_type: 2 + elem_type: 3 shape { dim { dim_value: 1 @@ -47,7 +34,7 @@ graph { name: "w" type { tensor_type { - elem_type: 2 + elem_type: 3 shape { dim { dim_value: 1 diff --git a/ngraph/test/models/onnx/conv_integer_overload.prototxt b/ngraph/test/models/onnx/conv_integer_overload.prototxt new file mode 100644 index 00000000000..28f780e6edb --- /dev/null +++ b/ngraph/test/models/onnx/conv_integer_overload.prototxt @@ -0,0 +1,109 @@ +ir_version: 7 +producer_name: "backend-test" +graph { + node { + input: "x" + input: "w" + input: "x_zero_point" + input: "w_zero_point" + output: "y" + op_type: "ConvInteger" + } + name: "ConvInt" + input { + name: "x" + type { + tensor_type { + elem_type: 2 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 3 + } + dim { + dim_value: 3 + } + } + } + } + } + input { + name: "w" + type { + tensor_type { + elem_type: 3 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } + input { + name: "x_zero_point" + type { + tensor_type { + elem_type: 2 + shape { + dim { + dim_value: 1 + } + } + } + } + } + input { + name: "w_zero_point" + type { + tensor_type { + elem_type: 3 + shape { + dim { + dim_value: 1 + } + } + } + } + } + output { + name: "y" + type { + tensor_type { + elem_type: 6 + shape { + dim { + dim_value: 1 + } + dim { + dim_value: 1 + } + dim { + dim_value: 2 + } + dim { + dim_value: 2 + } + } + } + } + } +} +opset_import { + domain: "" + version: 10 +} diff --git a/ngraph/test/models/onnx/conv_integer_pads.prototxt b/ngraph/test/models/onnx/conv_integer_vector_w_zero_point.prototxt similarity index 74% rename from ngraph/test/models/onnx/conv_integer_pads.prototxt rename to ngraph/test/models/onnx/conv_integer_vector_w_zero_point.prototxt index 14bbab23ed7..de26393029c 100644 --- a/ngraph/test/models/onnx/conv_integer_pads.prototxt +++ b/ngraph/test/models/onnx/conv_integer_vector_w_zero_point.prototxt @@ -1,35 +1,15 @@ -ir_version: 5 +ir_version: 7 producer_name: "nGraph ONNX Importer" graph { node { input: "x" input: "w" input: "x_zero_point" + input: "w_zero_point" output: "y" - name: "node1" op_type: "ConvInteger" - attribute { - name: "group" - i: 1 - type: INT - } - attribute { - name: "pads" - ints: 1 - ints: 1 - ints: 1 - ints: 1 - type: INTS - } - attribute { - name: "auto_pad" - s: "NOTSET" - type: STRING - } - doc_string: "ConvInteger" - domain: "" } - name: "test" + name: "ConvInt" input { name: "x" type { @@ -37,16 +17,16 @@ graph { elem_type: 2 shape { dim { - dim_value: 1 + dim_value: 2 } dim { dim_value: 1 } dim { - dim_value: 3 + dim_value: 4 } dim { - dim_value: 3 + dim_value: 4 } } } @@ -59,16 +39,16 @@ graph { elem_type: 2 shape { dim { - dim_value: 1 + dim_value: 2 } dim { dim_value: 1 } dim { - dim_value: 2 + dim_value: 3 } dim { - dim_value: 2 + dim_value: 3 } } } @@ -80,6 +60,22 @@ graph { tensor_type { elem_type: 2 shape { + dim { + dim_value: 1 + } + } + } + } + } + input { + name: "w_zero_point" + type { + tensor_type { + elem_type: 2 + shape { + dim { + dim_value: 2 + } } } } @@ -91,16 +87,16 @@ graph { elem_type: 6 shape { dim { - dim_value: 1 + dim_value: 2 } dim { - dim_value: 1 + dim_value: 2 } dim { - dim_value: 4 + dim_value: 2 } dim { - dim_value: 4 + dim_value: 2 } } } diff --git a/ngraph/test/onnx/onnx_import_quant.in.cpp b/ngraph/test/onnx/onnx_import_quant.in.cpp index 40b04a5f1cf..d08a4e8717e 100644 --- a/ngraph/test/onnx/onnx_import_quant.in.cpp +++ b/ngraph/test/onnx/onnx_import_quant.in.cpp @@ -751,52 +751,131 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_qlinear_matmul_3d) { test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, onnx_model_conv_integer) { +NGRAPH_TEST(${BACKEND_NAME}, onnx_model_conv_integer_simple_zero_point) { auto function = onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/conv_integer.onnx")); + auto test_case = test::TestCase(function); - test_case.add_input(std::vector{2, 3, 4, 5, 6, 7, 8, 9, 10}); // x - test_case.add_input(std::vector{1, 1, 1, 1}); // w - test_case.add_input(std::vector{1}); // x_zero_point + // don't change style for better readibility + // clang-format off + test_case.add_input(std::vector{11, 22, 33, + 44, 55, 66, + 77, 88, 99}); // x + test_case.add_input(std::vector{1, 2, + 3, 4}); // w + test_case.add_input(std::vector{111}); // x_zero_point + test_case.add_input(std::vector{1}); // w_zero_point - test_case.add_expected_output({1, 1, 2, 2}, std::vector{12, 16, 24, 28}); // y + test_case.add_expected_output({1, 1, 2, 2}, std::vector{-391, -325, + -193, -127}); // y + // clang-format on test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, onnx_model_conv_integer_zero_point_zero) { - auto function = onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/conv_integer.onnx")); +NGRAPH_TEST(${BACKEND_NAME}, onnx_model_conv_integer_int8) { + auto function = onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/conv_integer_int8.onnx")); + auto test_case = test::TestCase(function); - test_case.add_input(std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9}); // x - test_case.add_input(std::vector{1, 1, 1, 1}); // w - test_case.add_input(std::vector{0}); // x_zero_point + // don't change style for better readibility + // clang-format off + test_case.add_input(std::vector{-11, 22, -33, + 44, -55, 66, + -77, 88, -99}); // x + test_case.add_input(std::vector{ 1, -2, + -3, 4}); // w + test_case.add_input(std::vector{-5}); // x_zero_point + test_case.add_input(std::vector{-5}); // w_zero_point - test_case.add_expected_output({1, 1, 2, 2}, std::vector{12, 16, 24, 28}); // y + test_case.add_expected_output({1, 1, 2, 2}, std::vector{-307, 617, + 837, -747}); // y + // clang-format on test_case.run(); } NGRAPH_TEST(${BACKEND_NAME}, onnx_model_conv_integer_no_zero_point) { auto function = onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/conv_integer_no_zero_point.onnx")); + auto test_case = test::TestCase(function); - test_case.add_input(std::vector{1, 2, 3, 4, 5, 6, 7, 8, 9}); // x - test_case.add_input(std::vector{1, 1, 1, 1}); // w + // don't change style for better readibility + // clang-format off + test_case.add_input(std::vector{-100, -89, -78, + -67, -56, -45, + -34, -23, -12}); // x + test_case.add_input(std::vector{0, 1, + 2, 3}); // w - test_case.add_expected_output({1, 1, 2, 2}, std::vector{12, 16, 24, 28}); // y + test_case.add_expected_output({1, 1, 2, 2}, std::vector{-391, -325, + -193, -127}); // y + // clang-format on test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, onnx_model_conv_integer_pads) { - auto function = onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/conv_integer_pads.onnx")); +NGRAPH_TEST(${BACKEND_NAME}, onnx_model_conv_integer_vector_w_zero_point) { + auto function = onnx_import::import_onnx_model( + file_util::path_join(SERIALIZED_ZOO, "onnx/conv_integer_vector_w_zero_point.onnx")); + auto test_case = test::TestCase(function); - test_case.add_input(std::vector{2, 3, 4, 5, 6, 7, 8, 9, 10}); // x - test_case.add_input(std::vector{1, 1, 1, 1}); // w - test_case.add_input(std::vector{1}); // x_zero_point + // don't change style for better readibility + // clang-format off + test_case.add_input(std::vector{11, 22, 33, 44, + 55, 66, 77, 88, + 99, 88, 77, 66, + 55, 44, 33, 22, - test_case.add_expected_output({1, 1, 4, 4}, - std::vector{1, 3, 5, 3, 5, 12, 16, 9, 11, 24, 28, 15, 7, 15, 17, 9}); // y + 1, 2, 3, 4, + 5, 6, 7, 8, + 9, 10, 11, 12, + 13, 14, 15, 16}); // x + test_case.add_input(std::vector{2, 2, 3, + 4, 5, 6, + 7, 8, 9, + + 2, 2, 3, + 4, 5, 6, + 7, 8, 9}); // w + + test_case.add_input(std::vector{1}); // x_zero_point + test_case.add_input(std::vector{1, 2}); // w_zero_point + + test_case.add_expected_output({2, 2, 2, 2}, std::vector{2702, 2647, + 2174, 1855, + + 2183, 2095, + 1589, 1303, + + + 258, 295, + 406, 443, + + 213, 241, + 325, 353}); // y + // clang-format on + test_case.run(); +} + +NGRAPH_TEST(${BACKEND_NAME}, onnx_model_conv_integer_overload) { + auto function = + onnx_import::import_onnx_model(file_util::path_join(SERIALIZED_ZOO, "onnx/conv_integer_overload.onnx")); + + auto test_case = test::TestCase(function); + + // don't change style for better readibility + // clang-format off + test_case.add_input(std::vector{255, 255, 255, + 0, 0, 0, + 255, 255, 255}); // x + test_case.add_input(std::vector{127, -128, + -128, 127}); // w + test_case.add_input(std::vector{255}); // x_zero_point + test_case.add_input(std::vector{-128}); // w_zero_point + + test_case.add_expected_output({1, 1, 2, 2}, std::vector{-65025, -65025, + -65025, -65025}); // y + // clang-format on test_case.run(); } diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index c89881120c0..b7e86e39791 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -24,12 +24,6 @@ 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 -# Not supported ONNX op: QuantizedConvolution -onnx_model_conv_integer -onnx_model_conv_integer_zero_point_zero -onnx_model_conv_integer_no_zero_point -onnx_model_conv_integer_pads - # No support yet for RandomUniform onnx_model_random_uniform onnx_model_random_uniform_like diff --git a/ngraph/test/runtime/interpreter/unit_test.manifest b/ngraph/test/runtime/interpreter/unit_test.manifest index f5303fe192a..994d369dfdc 100644 --- a/ngraph/test/runtime/interpreter/unit_test.manifest +++ b/ngraph/test/runtime/interpreter/unit_test.manifest @@ -68,10 +68,6 @@ 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 -INTERPRETER.onnx_model_conv_integer -INTERPRETER.onnx_model_conv_integer_zero_point_zero -INTERPRETER.onnx_model_conv_integer_no_zero_point -INTERPRETER.onnx_model_conv_integer_pads # Legacy tests with unsupported features from opset4 LSTM/GRU/RNN # Peepholes input unsupported diff --git a/runtime/bindings/python/tests/__init__.py b/runtime/bindings/python/tests/__init__.py index d3a6791c18d..4143e4c4c03 100644 --- a/runtime/bindings/python/tests/__init__.py +++ b/runtime/bindings/python/tests/__init__.py @@ -74,8 +74,6 @@ xfail_issue_38724 = xfail_test(reason="RuntimeError: While validating ONNX node "half_pixel") xfail_issue_38725 = xfail_test(reason="RuntimeError: While validating ONNX node '