OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[ONNX] Added QLinearConcat from com.microsoft domain (#29535)
Vatsala Shanubhag95a10dfa0217
diff --git a/src/frontends/onnx/docs/supported_ops.md b/src/frontends/onnx/docs/supported_ops.mdindex ac61df0ce6e..9e23e3ba7a1 100644--- a/src/frontends/onnx/docs/supported_ops.md+++ b/src/frontends/onnx/docs/supported_ops.md@@ -273,7 +273,7 @@ OpenVINO provides support for operations of Default Opset (empty in table below)|com.microsoft |QGemm | |1 | ||com.microsoft |QLinearAdd |1 |1 | ||com.microsoft |QLinearAveragePool |1 |1 | |-|com.microsoft |QLinearConcat | |1 | |+|com.microsoft |QLinearConcat |1 |1 | ||com.microsoft |QLinearConv | |1 | ||com.microsoft |QLinearGlobalAveragePool | |1 | ||com.microsoft |QLinearLeakyRelu |1 |1 | |diff --git a/src/frontends/onnx/frontend/src/op/com.microsoft/qlinear_concat.cpp b/src/frontends/onnx/frontend/src/op/com.microsoft/qlinear_concat.cppnew file mode 100644index 00000000000..a94adf00d2d--- /dev/null+++ b/src/frontends/onnx/frontend/src/op/com.microsoft/qlinear_concat.cpp@@ -0,0 +1,61 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0++#include "core/operator_set.hpp"+#include "exceptions.hpp"+#include "openvino/frontend/exception.hpp"+#include "openvino/op/add.hpp"+#include "openvino/op/concat.hpp"+#include "openvino/op/convert.hpp"+#include "openvino/op/divide.hpp"+#include "openvino/op/multiply.hpp"+#include "openvino/op/subtract.hpp"+#include "utils/common.hpp"++using namespace ov::op;++namespace ov {+namespace frontend {+namespace onnx {+namespace com_microsoft {+namespace opset_1 {++ov::OutputVector qlinear_concat(const ov::frontend::onnx::Node& node) {+ common::default_op_checks(node, 3);++ auto inputs = node.get_ov_inputs();+ auto Y_scale = inputs[0];+ auto Y_zero_point = inputs[1];++ std::vector<std::shared_ptr<ov::Node>> dequantized_inputs;+ for (size_t i = 2; i < inputs.size(); i += 3) {+ auto X = inputs[i];+ auto X_scale = inputs[i + 1];+ auto X_zero_point = inputs[i + 2];++ auto X_minus_zero_point = std::make_shared<v1::Subtract>(X, X_zero_point);+ auto X_minus_zero_point_float = std::make_shared<v0::Convert>(X_minus_zero_point, X_scale.get_element_type());+ auto dequantized_X = std::make_shared<v1::Multiply>(X_scale, X_minus_zero_point_float);++ dequantized_inputs.push_back(dequantized_X);+ }++ auto axis = node.get_attribute_value<int64_t>("axis");+ auto concatenated =+ std::make_shared<v0::Concat>(ov::OutputVector(dequantized_inputs.begin(), dequantized_inputs.end()), axis);++ auto requantized = std::make_shared<v1::Divide>(concatenated, Y_scale);+ auto Y_zero_point_float = std::make_shared<v0::Convert>(Y_zero_point, Y_scale.get_element_type());+ auto Y_float = std::make_shared<v1::Add>(requantized, Y_zero_point_float);+ auto Y = std::make_shared<v0::Convert>(Y_float, inputs[2].get_element_type());++ return {Y};+}++ONNX_OP("QLinearConcat", OPSET_SINCE(1), com_microsoft::opset_1::qlinear_concat, MICROSOFT_DOMAIN);++} // namespace opset_1+} // namespace com_microsoft+} // namespace onnx+} // namespace frontend+} // namespace ovdiff --git a/src/frontends/onnx/tests/models/com.microsoft/qlinear_concat_i8.prototxt b/src/frontends/onnx/tests/models/com.microsoft/qlinear_concat_i8.prototxtnew file mode 100644index 00000000000..3205827d396--- /dev/null+++ b/src/frontends/onnx/tests/models/com.microsoft/qlinear_concat_i8.prototxt@@ -0,0 +1,141 @@+ir_version: 3+producer_name: "OpenVINO ONNX Frontend"+producer_version: ""+model_version: 0+graph {+ name: "test_qlinear_concat_i8"++ node {+ input: "Y_scale"+ input: "Y_zero_point"+ input: "X1"+ input: "X1_scale"+ input: "X1_zero_point"+ input: "X2"+ input: "X2_scale"+ input: "X2_zero_point"+ output: "Y"+ op_type: "QLinearConcat"+ attribute {+ name: "axis"+ i: 1+ type: INT+ }+ domain: "com.microsoft"+ }++ input {+ name: "Y_scale"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim { dim_value: 1 }+ }+ }+ }+ }++ input {+ name: "Y_zero_point"+ type {+ tensor_type {+ elem_type: 3+ shape {+ dim { dim_value: 1 }+ }+ }+ }+ }++ input {+ name: "X1"+ type {+ tensor_type {+ elem_type: 3+ shape {+ dim { dim_value: 2 }+ dim { dim_value: 2 }+ }+ }+ }+ }++ input {+ name: "X1_scale"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim { dim_value: 1 }+ }+ }+ }+ }++ input {+ name: "X1_zero_point"+ type {+ tensor_type {+ elem_type: 3+ shape {+ dim { dim_value: 1 }+ }+ }+ }+ }++ input {+ name: "X2"+ type {+ tensor_type {+ elem_type: 3+ shape {+ dim { dim_value: 2 }+ dim { dim_value: 2 }+ }+ }+ }+ }++ input {+ name: "X2_scale"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim { dim_value: 1 }+ }+ }+ }+ }++ input {+ name: "X2_zero_point"+ type {+ tensor_type {+ elem_type: 3+ shape {+ dim { dim_value: 1 }+ }+ }+ }+ }++ output {+ name: "Y"+ type {+ tensor_type {+ elem_type: 3+ shape {+ dim { dim_value: 2 }+ dim { dim_value: 4 }+ }+ }+ }+ }+}++opset_import {+ version: 1+}diff --git a/src/frontends/onnx/tests/models/com.microsoft/qlinear_concat_u8.prototxt b/src/frontends/onnx/tests/models/com.microsoft/qlinear_concat_u8.prototxtnew file mode 100644index 00000000000..66ebc50093a--- /dev/null+++ b/src/frontends/onnx/tests/models/com.microsoft/qlinear_concat_u8.prototxt@@ -0,0 +1,141 @@+ir_version: 3+producer_name: "OpenVINO ONNX Frontend"+producer_version: ""+model_version: 0+graph {+ name: "test_qlinear_concat_u8"++ node {+ input: "Y_scale"+ input: "Y_zero_point"+ input: "X1"+ input: "X1_scale"+ input: "X1_zero_point"+ input: "X2"+ input: "X2_scale"+ input: "X2_zero_point"+ output: "Y"+ op_type: "QLinearConcat"+ attribute {+ name: "axis"+ i: 1+ type: INT+ }+ domain: "com.microsoft"+ }++ input {+ name: "Y_scale"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim { dim_value: 1 }+ }+ }+ }+ }++ input {+ name: "Y_zero_point"+ type {+ tensor_type {+ elem_type: 2+ shape {+ dim { dim_value: 1 }+ }+ }+ }+ }++ input {+ name: "X1"+ type {+ tensor_type {+ elem_type: 2+ shape {+ dim { dim_value: 4 }+ dim { dim_value: 6 }+ }+ }+ }+ }++ input {+ name: "X1_scale"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim { dim_value: 1 }+ }+ }+ }+ }++ input {+ name: "X1_zero_point"+ type {+ tensor_type {+ elem_type: 2+ shape {+ dim { dim_value: 1 }+ }+ }+ }+ }++ input {+ name: "X2"+ type {+ tensor_type {+ elem_type: 2+ shape {+ dim { dim_value: 4 }+ dim { dim_value: 6 }+ }+ }+ }+ }++ input {+ name: "X2_scale"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim { dim_value: 1 }+ }+ }+ }+ }++ input {+ name: "X2_zero_point"+ type {+ tensor_type {+ elem_type: 2+ shape {+ dim { dim_value: 1 }+ }+ }+ }+ }++ output {+ name: "Y"+ type {+ tensor_type {+ elem_type: 2+ shape {+ dim { dim_value: 4 }+ dim { dim_value: 12 }+ }+ }+ }+ }+}++opset_import {+ version: 1+}diff --git a/src/frontends/onnx/tests/onnx_import_com_microsoft.in.cpp b/src/frontends/onnx/tests/onnx_import_com_microsoft.in.cppindex 74070978cc6..7d0f564233a 100644--- a/src/frontends/onnx/tests/onnx_import_com_microsoft.in.cpp+++ b/src/frontends/onnx/tests/onnx_import_com_microsoft.in.cpp@@ -2145,6 +2145,74 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_model_gqa_past_1_input_1_rotary_interleaved)test_case.run_with_tolerance_as_fp();}+OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_qlinear_concat_i8) {+ const auto model = convert_model("com.microsoft/qlinear_concat_i8.onnx");+ auto test_case = ov::test::TestCase(model, s_device);++ const std::vector<float> y_scale{0.1f};+ const std::vector<int8_t> y_zero_point{5};++ const std::vector<int8_t> X1{1, 2, 3, 4};+ const std::vector<float> X1_scale{0.1f};+ const std::vector<int8_t> X1_zero_point{0};++ const std::vector<int8_t> X2{5, 6, 7, 8};+ const std::vector<float> X2_scale{0.1f};+ const std::vector<int8_t> X2_zero_point{0};++ const std::vector<int8_t> expected_output{6, 7, 10, 11, 8, 9, 12, 13};++ test_case.add_input<float>(Shape{1}, y_scale);+ test_case.add_input<int8_t>(Shape{1}, y_zero_point);++ test_case.add_input<int8_t>(Shape{2, 2}, X1);+ test_case.add_input<float>(Shape{1}, X1_scale);+ test_case.add_input<int8_t>(Shape{1}, X1_zero_point);++ test_case.add_input<int8_t>(Shape{2, 2}, X2);+ test_case.add_input<float>(Shape{1}, X2_scale);+ test_case.add_input<int8_t>(Shape{1}, X2_zero_point);++ test_case.add_expected_output<int8_t>(Shape{2, 4}, expected_output);+ test_case.run();+}++OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_qlinear_concat_u8) {+ const auto model = convert_model("com.microsoft/qlinear_concat_u8.onnx");+ auto test_case = ov::test::TestCase(model, s_device);++ const std::vector<float> y_scale{0.1f};+ const std::vector<uint8_t> y_zero_point{5};++ const std::vector<uint8_t> X1{10, 20, 30, 40, 50, 60, 15, 25, 35, 45, 55, 65,+ 12, 22, 32, 42, 52, 62, 18, 28, 38, 48, 58, 68};+ const std::vector<float> X1_scale{0.1f};+ const std::vector<uint8_t> X1_zero_point{0};++ const std::vector<uint8_t> X2{70, 80, 90, 100, 110, 120, 75, 85, 95, 105, 115, 125,+ 72, 82, 92, 102, 112, 122, 78, 88, 98, 108, 118, 128};+ const std::vector<float> X2_scale{0.1f};+ const std::vector<uint8_t> X2_zero_point{0};++ const std::vector<uint8_t> expected_output{+ 15, 25, 35, 45, 55, 65, 75, 85, 95, 105, 115, 125, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130,+ 17, 27, 37, 47, 57, 67, 77, 87, 97, 107, 117, 127, 23, 33, 43, 53, 63, 73, 83, 93, 103, 113, 123, 133};++ test_case.add_input<float>(Shape{1}, y_scale);+ test_case.add_input<uint8_t>(Shape{1}, y_zero_point);++ test_case.add_input<uint8_t>(Shape{4, 6}, X1);+ test_case.add_input<float>(Shape{1}, X1_scale);+ test_case.add_input<uint8_t>(Shape{1}, X1_zero_point);++ test_case.add_input<uint8_t>(Shape{4, 6}, X2);+ test_case.add_input<float>(Shape{1}, X2_scale);+ test_case.add_input<uint8_t>(Shape{1}, X2_zero_point);++ test_case.add_expected_output<uint8_t>(Shape{4, 12}, expected_output);+ test_case.run();+}+OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_qlinearsoftmax) {const auto model = convert_model("com.microsoft/qlinear_softmax_opset13.onnx");auto test_case = ov::test::TestCase(model, s_device);