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 Range from com.microsoft domain (#28202)
Bhuminjay Soni62b720d180d5
diff --git a/src/frontends/onnx/frontend/src/op/com.microsoft/range.cpp b/src/frontends/onnx/frontend/src/op/com.microsoft/range.cppnew file mode 100644index 00000000000..8740869ef8d--- /dev/null+++ b/src/frontends/onnx/frontend/src/op/com.microsoft/range.cpp@@ -0,0 +1,44 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "openvino/op/range.hpp"++#include "core/operator_set.hpp"+#include "exceptions.hpp"+#include "openvino/op/constant.hpp"+#include "utils/common.hpp"++using namespace ov::op;++namespace ov {+namespace frontend {+namespace onnx {+namespace com_microsoft {+namespace opset_1 {+ov::OutputVector range(const ov::frontend::onnx::Node& node) {+ common::default_op_checks(node, 2);+ auto nodes = node.get_ov_inputs();++ auto start = nodes[0];+ auto limit = nodes[1];+ auto delta =+ nodes.size() == 3 ? nodes[2] : ov::op::v0::Constant::create(start.get_element_type(), ov::Shape{}, {1});+ CHECK_VALID_NODE(node,+ start.get_element_type() == limit.get_element_type(),+ "start and limit must be of same type, got :",+ start.get_element_type(),+ limit.get_element_type());+ CHECK_VALID_NODE(node,+ start.get_element_type() == delta.get_element_type(),+ "start and delta must be of same type, got :",+ start.get_element_type(),+ delta.get_element_type());+ return {std::make_shared<ov::op::v4::Range>(start, limit, delta, start.get_element_type())};+}+ONNX_OP("Range", OPSET_SINCE(1), com_microsoft::opset_1::range, MICROSOFT_DOMAIN);+} // namespace opset_1+} // namespace com_microsoft+} // namespace onnx+} // namespace frontend+} // namespace ov\ No newline at end of filediff --git a/src/frontends/onnx/tests/models/com.microsoft/range_with_delta.prototxt b/src/frontends/onnx/tests/models/com.microsoft/range_with_delta.prototxtnew file mode 100644index 00000000000..af66b46bc85--- /dev/null+++ b/src/frontends/onnx/tests/models/com.microsoft/range_with_delta.prototxt@@ -0,0 +1,60 @@+ir_version: 6+producer_name: "OpenVINO ONNX Frontend"+graph {+ node {+ input: "start"+ input: "limit"+ input: "delta"+ output: "output"+ op_type: "Range"+ domain: "com.microsoft"+ }+ name: "test_range_float_type_with_delta"+ input {+ name: "start"+ type {+ tensor_type {+ elem_type: 1+ shape {+ }+ }+ }+ }+ input {+ name: "limit"+ type {+ tensor_type {+ elem_type: 1+ shape {+ }+ }+ }+ }+ input {+ name: "delta"+ type {+ tensor_type {+ elem_type: 1+ shape {+ }+ }+ }+ }+ output {+ name: "output"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 10+ }+ }+ }+ }+ }+}+opset_import {+ version: 1+ domain: "com.microsoft"+}diff --git a/src/frontends/onnx/tests/models/com.microsoft/range_without_delta.prototxt b/src/frontends/onnx/tests/models/com.microsoft/range_without_delta.prototxtnew file mode 100644index 00000000000..b8ac7a98779--- /dev/null+++ b/src/frontends/onnx/tests/models/com.microsoft/range_without_delta.prototxt@@ -0,0 +1,49 @@+ir_version: 6+producer_name: "OpenVINO ONNX Frontend"+graph {+ node {+ input: "start"+ input: "limit"+ output: "output"+ op_type: "Range"+ domain: "com.microsoft"+ }+ name: "test_range_float_type_without_delta"+ input {+ name: "start"+ type {+ tensor_type {+ elem_type: 1+ shape {+ }+ }+ }+ }+ input {+ name: "limit"+ type {+ tensor_type {+ elem_type: 1+ shape {+ }+ }+ }+ }+ output {+ name: "output"+ type {+ tensor_type {+ elem_type: 1+ shape {+ dim {+ dim_value: 10+ }+ }+ }+ }+ }+}+opset_import {+ version: 1+ domain: "com.microsoft"+}diff --git a/src/frontends/onnx/tests/onnx_import_com_microsoft.in.cpp b/src/frontends/onnx/tests/onnx_import_com_microsoft.in.cppindex 246315a9e03..47a336f1749 100644--- a/src/frontends/onnx/tests/onnx_import_com_microsoft.in.cpp+++ b/src/frontends/onnx/tests/onnx_import_com_microsoft.in.cpp@@ -1483,6 +1483,29 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_simplified_layer_normalizationtest_case.run();}+OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_range_with_delta) {+ const auto model = convert_model("com.microsoft/range_with_delta.onnx");+ auto test_case = ov::test::TestCase(model, s_device);++ test_case.add_input<float>({0.f});+ test_case.add_input<float>({10.f});+ test_case.add_input<float>({1.f});+ test_case.add_expected_output<float>(Shape{10}, {0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f});++ test_case.run();+}++OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_range_without_delta) {+ const auto model = convert_model("com.microsoft/range_without_delta.onnx");+ auto test_case = ov::test::TestCase(model, s_device);++ test_case.add_input<float>({0.f});+ test_case.add_input<float>({10.f});+ test_case.add_expected_output<float>(Shape{10}, {0.f, 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f});++ test_case.run();+}+OPENVINO_TEST(${BACKEND_NAME}, onnx_com_microsoft_fusedmatmul_2x3) {const auto model = convert_model("com.microsoft/fusedmatmul_2D.onnx");auto test_case = ov::test::TestCase(model, s_device);